Assigning a javascript object with and object inside an array -


i curious this.

let's have array of objects , create 1 object, lets name array of objects items , object item.

i want particular item in array of items using following code:

//gets item base on id function get_item(td){     var item = undefined;     $.each(items, function(i, val) {         if(val.item_id == td){             item = val;         }        });     return item; } 

the get_item() gets object matched supplied id.

so question this. if changed properties of item changed properties of object associated within array?

thank much!

what if changed properties of item changed properties of object associated within array?

yes.

objects not copied. instead, references objects passed around. simplest example:

var = []; var b = a; b.push(1); console.log(a); // logs [1] 

many object-oriented programming languages work this.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -