Gareth Redfern developer, cyclist & coffee lover

Javascript Objects

Posted by Gareth Redfern
Category: javascript

In this example we are storing the object’s properties by value. What this means is that cb is stored in memory, when you change the value of box.material to Steel it doesn’t change the value of cb. Both the console.log(cb); will display cardboard as cb has stored the value cardboard in memory.

var box = {};

box.material = "Cardboard";

var cb = box.material;

console.log(cb);

box.material = "Steel";

console.log(cb);

For more Javascript learning check out my Codepen collection.