Your problem is two-fold.
Problem 1:
Object.create should be passed the prototype, not the constructor. In this case, you should use Object.create(person.prototype);, not Object.create(person);
Problem 2:
The say property is added when the constructor is called, and you never call the parent constructor from the child constructor.
There are a couple ways to solve this, depending on your desired behavior.
Option 1, call parent constructor.
person.call(this);
Sample:
function person() {
this.say="hello";
}
function man() {
person.call(this);
this.name="John Miler";
}
man.prototype = Object.create(person.prototype);
var Johnny = new man();
console.log(Johnny.say);
Option 2, make it a static property.
person.prototype.say = "hello";
Sample:
function person() {
}
person.prototype.say = "hello";
function man() {
this.name="John Miler";
}
man.prototype = Object.create(person.prototype);
var Johnny = new man();
console.log(Johnny.say);
parameterofObject.createshould be prototype, not constructor (as you supplied). Passperson.prototypeinstead ofperson{}or alsonull. All the properties in that object will be inherited, no matter which of the type they are.