window.value=1;
function getValue(){
console.log(this.value);
}
getValue();//输出1,此时的this指向window
var Obj={
value:2,
getValue:function(){
console.log(this.value);//输出2,this指向Obj
}
}
function main(val){
this.value=val;
}
main.prototype.getValue=function(){
console.log(this.value);
}
var fun=new main(3);
fun.getValue();
fun.value;//输出3,this指向main的实例对象fun
function showValue(){
console.log(this.value);
}
var obj={
value:4
}
showValue.call(obj)//输出4,this指向了obj对象
function showValue(){
console.log(this.value);
}
var obj={
value:4
}
var showValue2=showValue.bind(obj);
showValue2()//输出4,this指向了obj对象
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有