热门

最新

红包

立Flag

投票

同城

我的

发布
weixin_47095569
记录小作文
3 年前
trueweixin_47095569

toString()方法 和this指向
JavaScript中定义了其中数据类型 Boolean number string undefined null symbol object 除了undefined和null类型外 都有toString() 方法

this的指向
1 严格模式下全局作用域中的this指向window对象
‘use strict’
console.log(this === window) // true
2 严格模式下在全局作用域中函数的this指向undefined ,反之指向window
例子: // 'use strict'
function fn() {
console.log('fn 中的this', this);
function fn2() {
console.log('fn2中的this', this);
}
fn2()
}
fn()

CSDN App 扫码分享
分享
评论
点赞
打赏
  • 复制链接
  • 举报
下一条:
一本校招有机会进大厂果断进!待个两三年在考虑是留是跳都非常主动且轻松
立即登录