How to Update an Object in JavaScript
In JavaScripot, updating a variable is quite straitforward. We assign a nnew value to the variable like this. var name = "John"; name = "Joe"; //variable name has been chagned from John to Joe. Waht about an object? Updating a property of an object is the same way we do with varialbes. <script> var obj = { name:"John", age:10, call:function(){ console.log("My name is " + this.name + "."); } }; obj.age = 11; console.log(obj.age); // 11 </script> Updating mothods in an object We can also update the methods the same we way we do with updating object property <script> var obj = { name:"John", age:10, call:function(){ console.log("My name is " + this.name + "."); } }; obj.call(); //My name is John. obj.call = function(){ console.log("I'm " + this.age + " years old."); } obj.call(); //I'm 11 years old. </script> Creating new object...