this的应用
//this
//1.函数预编译过程中 this指向windows
// function text() {
// console.log(this);//[object Window]
// }
//text();
//2.全局作用域里 this指向windows
//3.call和apply 改变函数指向的this
//4.谁调用函数this指向谁
// var obj = {
// a : function () {
// console.log(this.name)
// },
// name : 'abc'
// }
// obj.a();
//练习题
// var name = "222";
// var a = {
// name : "111",
// say : function () {
// console.log(this.name);
// }
// }
// var fun = a.say;
// fun()//222
// a.say()//111
// var b = {
// name : '333',
// say : function (fun) {
// //fun();
// console.log(this);
// }
// }
// b.say(a.say);//222
// b.say = a.say;
// b.say();//333
浙公网安备 33010602011771号