Function.prototype.myFunc = function(){
console.log(2222222222);
}
Object.prototype.myFunc = function(){
console.log(2222222222);
}
静态成员只有自己含有
ldh.myFun();
console.log(ldh.name);
console.log(ldh.__proto__.constructor.sex);
ldh.__proto__.sumFun();
ldh.__proto__.constructor.sumFun();
console.log(ldh);
constructor静态方法
console.log(Star.prototype.constructor.sex);
console.log(ldh.__proto__.constructor.sex);
var xyz=new Star('周润发',20);
console.log(Star.prototype.sex);
console.log(Star.sex);
console.log(Star.prototype);
console.log(ldh.__proto__.sex);
console.log(ldh.sex);
ldh.__proto__.sumFun();
ldh.sumFun();
ldh.myFunc();
Star.myFunc();
Star("朱攀佳",3)
function func(){
console.log(this.name);
sing();
}
func();
var ldh=new Star('刘德华',18);
console.log(typeof ldh);
console.log(ldh);
ldh.sing();
ldh.name = "陈冬";
console.log(ldh);
Star.sex = "男";
console.log(Star.sex);
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
</body>
<script type="text/javascript">
// 原型
function Star(name,age){
this.name=name;
this.age=age;
this.sing=function(){
console.log('唱歌')
}
}
// Function.prototype.myFunc = function(){
// console.log(2222222222);
// }
// Object.prototype.myFunc = function(){
// console.log(2222222222);
// }
// 静态成员只有自己含有
Star.sex = "女";
Star.prototype.sex = "男";
Star.prototype.sumFun = function(){
console.log(1111111111);
}
Object.prototype.myFun = function(){
console.log(2222222222);
}
var ldh=new Star('刘德华',18);
// ldh.myFun();
// console.log(ldh.name);
// console.log(ldh.__proto__.constructor.sex);
// ldh.__proto__.sumFun();
// ldh.__proto__.constructor.sumFun();
// console.log(ldh);
// constructor静态方法
// console.log(Star.prototype.constructor.sex);
// console.log(ldh.__proto__.constructor.sex);
// var xyz=new Star('周润发',20);
// console.log(Star.prototype.sex);
// console.log(Star.sex);
// console.log(Star.prototype);
// console.log(ldh.__proto__.sex);
// console.log(ldh.sex);
// ldh.__proto__.sumFun();
// ldh.sumFun();
// ldh.myFunc();
// Star.myFunc();
// Star("朱攀佳",3)
// function func(){
// console.log(this.name);
// sing();
// }
// func();
// var ldh=new Star('刘德华',18);
// console.log(typeof ldh);
// console.log(ldh);
// ldh.sing();
// ldh.name = "陈冬";
// console.log(ldh);
// Star.sex = "男";
// console.log(Star.sex);
</script>
</html>