js中this的指向问题
在函数中直接使用
function get(content){
console.log(this.content)
}
get("你好") //等价于get.call(window, "你好")
函数作为对象的方法被调用(谁调用我,我就指向谁)
var person = {
name:"zhangsan"
run:function(time){
console.log(`$(this.name) 在跑步,最多$(time)min就不行了`)
...
原创
2021-07-05 16:17:09 ·
81 阅读 ·
0 评论