setPrototypeOf

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<script>
var hmm={
sname:"Han Meimei",
sage:11,
intr(){
console.log(`I'm ${this.sname},I'm${this.sage}`);
}
}//__proto__->Object.prototype
hmm.intr();
var father={bal:10000000,car:"infiniti"};
//让hmm继承father
Object.getPrototypeOf(hmm,father);
console.dir(hmm);
</script>
</body>
</html>
posted @ 2018-07-24 19:08  BugLess000  阅读(160)  评论(0编辑  收藏  举报