Methods are functions that have the `this` bonus param assigned to the object that the method was called on. - Node.js Object

Node.js examples for Object:Object Operation

Description

Methods are functions that have the `this` bonus param assigned to the object that the method was called on.

Demo Code


/**//from   ww  w. java  2  s  .com
 * Objects have properties and methods
 *
 * Methods are functions that have the `this` bonus param assigned to
 * the object that the method was called on.
 */

function sayHello(){
  console.log("Regular ol' function call", this);
}

sayHello();


var zuri = {
  name: 'Zuri',
  sayHello: function(){
      console.log('method function call. This:', this);
  }
};

zuri.sayHello();

Related Tutorials