//Function Constructor : Person has an instance property : name
function Person(name){ = name;

//Person Instances
let john = new Person('John');
let sara = new Person('Sara');

console.log(; //John
console.log(; //Sara

Person.prototype.walk = function(){
  console.log( + ' is walking.');

john.walk(); //John is walking
sara.walk(); //Sara is walking

//Programmer Constructor : Wants to inherit Person
function Programmer(name, programmingLanguage){, name);
  this.programmingLanguage = programmingLanguage || '';

Programmer.prototype = Object.create(Person.prototype);
Programmer.prototype.constructor = Programmer;

var snig = new Programmer('Snigdha', 'Javascript');

downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter