17. "This" works for everyone example w/ use of Literal


#1

Example of using a literal to create the object susan with subsequent changing of age property via the method setAge.


var setAge = function (newAge) {
  this.age = newAge;
};

// Use of literal to creat object susan
var susan = {
    age: 25,
    setAge: setAge};
    
console.log("susan.age = " + susan.age);
// susan's age is 25

susan.setAge(35);

console.log("susan.age = " + susan.age);
// susan's age is now 35


#2

Is this a question?? :confused: