js分号踩坑记录

1.缺少分号导致的报错

在test()后面加上一个分号就能正常打印

const person = {
  name: "person",
  a: function () {
    console.log(this)
  }
}

function test() {
  (person.a)()
}               

person.a()      //person对象
test()          //person对象
(person.a)()    //Uncaught TypeError: test(...) is not a function    ?
posted @ 2020-10-19 14:27    阅读(109)  评论(0编辑  收藏  举报