<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script>
// ES6 允许在对象中使用 super 方法:
var father = {
foo(){
console.log("Hello from the father");
}
}
var child ={
foo(){
super.foo();
console.log('Hello from the Child')
}
}
/*
语法
Object.setPrototypeOf(obj, prototype)
参数
obj
将被设置原型的对象.
prototype
该对象新的原型(可以是一个对象或者null).
*/
Object.setPrototypeOf(child,father);
child.foo(); // Hello from the father
// Hello from the Child
</script>
</body>
</html>