Node.js examples for Object:Constructor
Constructors are function calls with the `new` keyword
/**//from w w w . j a v a2 s. co m * Constructors are function calls with the `new` keyword */ // var dog = { // height: 'short' // }; // // var kepler = dog; // var oliver = dog; // oliver.height = 'tall'; // console.log(kepler); // console.log(oliver); function Dog(height){ console.log('Constructor. This:', this); this.height = height; this.wag = function(thing){ console.log('Wag ' + thing); }; } var kepler = new Dog('short'); var oliver = new Dog('tall'); kepler.wag('tail'); oliver.wag('whole body'); oliver.height = 'medium'; console.log(kepler);