通过 Object.create() 方法,使用一个指定的原型对象和一个额外的属性对象创建一个新对象。这是一个用于对象创建、继承和重用的强大的新接口。说直白点,就是一个新的对象可以继承一个对象的属性,并且可以自行添加属性。
var
parents = {
name :
"UW3C"
,
bron :
"2013"
,
from :
"China"
}
var
child = Object.create(
parents,
{
title : {
value :
"技术分享"
,
},
year : {
value :
"2"
,
}
}
);
alert(child.name + child.title +
"创建于"
+ child.bron +
"今年"
+ child.year +
"岁了~"
);