Object prototype in JavaScript - Node.js Object

Node.js examples for Object:Prototype

Description

Object prototype in JavaScript

Demo Code



function User(name){
  this.name = name;/* w  ww .  ja  v a 2 s.c o  m*/
}


// 1.
User.prototype.age = 32;

console.log(User.prototype);
console.log(Object.prototype.prototype);


var user = new User("davy");
console.log(user.age);

User.prototype = {age: 20};

console.log(User.prototype);

var user = new User("Davy");
console.log(User.prototype.prototype);

console.log(Function.prototype.prototype);

console.log(Number.prototype.prototype);

console.log(Boolean.prototype.prototype);

Related Tutorials