Leo Liu's blog

Archives · 2022

Home

About

Archives

JavascriptObject

What Did new Keyword, Object.create() Do In Javascript

We can use both new and Object.create() implement inherantance in javascript: // new function People(name) { this.name = name; } People.prototype.sayName = function () { console.log(this.name); }; var leo = new People("leo"); // object.create() var People = { name: "liu", sayName() { console...

Read more