Node.js examples for Object:Constructor
Constructor Function to create Person class
function Person (firstName, lastName) { this.firstName = firstName,/*from www .j a v a 2s. c o m*/ this.lastName = lastName; } //the proto doesnt actualy become part of the object, but gives access to it Person.prototype.greeting = function() { console.log('Hello ' + this.firstName + ' ' + this.lastName); }; var john = new Person('John', 'Seyfert'); console.log(john.greeting()); console.log(john.__proto__); // dont do this in production console.log(john); //does not show proto in obj because the proto in not part of obj, just accessable