Javascript Object Work as Reference Types

Description

Javascript Object Work as Reference Types



let myAlarm = {time: 5000, description: "Call Lara."};

// Now let's assign the object to a new identifier
let myAlarm2 = myAlarm;

// And change the original object somehow
myAlarm.time = 100;/*w w w  .j a  v a2 s. c o m*/

// Check to see if our identifier is changed too
console.log("myAlarm2.time: " + myAlarm2.time );  // 100



PreviousNext

Related