Objects are mutable, Passed by sharing - Node.js Object

Node.js examples for Object:Object Operation

Description

Objects are mutable, Passed by sharing

Demo Code


/**/*from   w ww .jav a 2 s. com*/
 * Objects are mutable
 * Passed by sharing
 */

var kepler = {
  likes: 'treats'
};

console.log(kepler);


function likeSomethingNew(dog){
  // dog.likes = 'balls';
  dog.isHungry = true;
  delete dog.likes;
  console.log(dog);
}

likeSomethingNew(kepler);
console.log(kepler);

Related Tutorials