1. 首页
  2. 数据库
  3. 其它
  4. javascript中的this绑定

javascript中的this绑定

上传者: 2021-01-17 02:04:36上传 PDF文件 33KB 热度 8次
this是一个关键字,表示执行当前函数的对象 this永远跟着当前函数走, 永远是一个对象, 永远在函数执行时才能确定。 1. 默认绑定:没有明确被隶属对象执行的函数,this指向window function fn(){ console.log(this); //window console.log(typeof this); //object } fn(); – 严格模式下,this指向undefiend use strict; function fn(){ console.log(this); //undefined } fn(); 2. 隐式绑定:明确被隶属
下载地址
用户评论