JSFiddle - React, Tailwind, and code Playground

by deepak sisodiya

JavaScript

// prototype chain

var alert  = function (str) {
   var st = document.createTextNode(str);
   var p = document.createElement('p');
   p.appendChild(st);
   document.querySelector('body').appendChild(p);
}

//var person = Object.create(Object.prototype)
var person = {
    firstName:"deepak",
    lastName:"sisodiya"
}

// inherit person object
var anotherObject = Object.create(person)

alert(person.firstName);

anotherObject.firstName = "chetan"
alert(anotherObject.firstName)
alert(anotherObject.lastName)

alert(person.hasOwnProperty('firstName'))          // true
alert(anotherObject.hasOwnProperty('firstName'))   // true
alert(anotherObject.hasOwnProperty('lastName'))    // false