JS Prototype

<script type="text/javascript">


function employee(name,job,born)
{
this.name=name;
this.job=job;
this.born=born;
this.abc = "abcde";
/*this.hobby=function(){
 return 'watching movies';
 }*/
}
employee.prototype.hobby=function(){
 return 'watching movies';
 }
 document.write(typeof employee.prototype);
var bill=new employee("Bill Gates","Engineer",1985);


employee.prototype.salary=null;
employee.prototype.age = 123;
bill.salary=20000;


document.write(bill.salary);
document.write(bill.age);
document.write(employee.prototype.age);
document.write(bill.abc);


var bill2=new employee("Bill 2Gates","Engine2er",19825);
document.write(bill2.hobby===bill.hobby);
document.write(bill.hobby);
document.write(bill2.hobby);
console.log(Object.getPrototypeOf(Object.prototype));
console.log(employee.prototype.isPrototypeOf(bill));
console.log(bill instanceof employee);
console.log(null instanceof Object);
console.log(undefined instanceof Object);


function A() {};
A.prototype.hello = function() {
return new this.constructor();
}


function Father() {} 
 function Son() {
Son.height.constructor.call(this);
 } 
 Son.height = new Father();


</script>
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值