45 lines
1.1 KiB
HTML
45 lines
1.1 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Document</title>
|
|
<script>
|
|
function timi(){
|
|
this.start=function(){
|
|
console.log('timi')
|
|
}
|
|
}
|
|
var tianmei=new timi()
|
|
|
|
function create(age,name,hobby){
|
|
this.age=age;
|
|
this.name=name;
|
|
this.hobby=hobby
|
|
}
|
|
create.prototype=tianmei
|
|
create.prototype.run=function(){
|
|
console.log("我会跑")
|
|
}
|
|
|
|
// create.prototype.timi=new timi();
|
|
|
|
|
|
console.log(create.prototype)
|
|
var zhansan = new create("24","zhansan","book")
|
|
var xiaoqiao=new create("18","小乔","蹲草")
|
|
console.log(zhansan)
|
|
zhansan.run()
|
|
xiaoqiao.run()
|
|
// console.log(zhansan.__proto__)
|
|
// 对象访问原型是通过 __proto__ 属性
|
|
// 函数访问 原型是通过 prototype属性
|
|
|
|
|
|
</script>
|
|
</head>
|
|
<body>
|
|
|
|
</body>
|
|
</html> |