Object.create()

Object.create方法是ES5才引入的方法,目前尚不能在开发中应用。

使用方法示例:

var person = {

  name : "chen",

  sayName : function(){

    alert(this.name);

  }

}

1.

var myPerson = Object.create(person);

myPerson.sayName() //chen

2.

var myPerson = Object.create(person, {

  name:{

    value : "liang"

  }

});

myPerson.sayName(); //liang

原文地址:https://www.cnblogs.com/charling/p/3383543.html