let's see what is done in the code -
var setAge = function (newAge) { this.age = newAge; };
here a function is defined that will change the age of an object variable to that specified when the function is called.
var susan = new Object(); susan.age = 25; susan.mynewageis = setAge;
here we set the predefined value susan.age to be changed by the function, and we set the function value of the susan.mynewageis variable to make this function available next time in any other case.
susan.mynewageis(35);
here we set susan.age to 35, as indicated by the function call.
I was about to post this answer, but by mistake I hit the submit button and sent an incomplete answer.
source share