Object Reference: Push vs. Hash

by darcyclarke

JavaScript

var temp = '', 
    myArray = [{'test':1},{'test':2}], 
    myFunc = function(val){ myArray.push({'name': val}); return myArray[(myArray.length-1)]; };
                                                   
   temp = myFunc('one');
   temp.test = 'what up';

console.log(myArray[2]);
console.log(myArray);