Normally altering a reference to an object/array, alters the object and vice versa.
var someArr = [{letter: 'a'}, {letter: 'b'}, {letter: 'c'}];
var test = someArr[1];
test.letter = 'k';
// or
// someArr[1].letter = 'k'
console.log(test.letter); // outputs k
console.log(someArr[1].letter); // outputs k
A reference to an array index' value (which is an object) won't change if the value of said index changes - e.g. if the value is removed via splice, the reference won't point to the new value that took it's place at that index. It still holds the reference to the removed value. Why?
var someArr = [{letter: 'a'}, {letter: 'b'}, {letter: 'c'}];
var test = someArr[1];
someArr.splice(1, 1); // remove object with letter b
console.log(test.letter); // outputs b <-- Why not c?
console.log(someArr[1].letter); // outputs c
Here is a JSFiddle http://jsfiddle.net/rf47jyxv/
I don't want to know that it is like that. I know it is like that. I would like to know why it is like that.
Why, after splice, is the variable test that holds a reference to someArr[1] different than calling someArr[1] directly?
someArr[1]