JSLint Error: Unexpected 'this'

后端 未结 6 1523
野趣味
野趣味 2020-12-03 01:02

Having trouble understanding why JSLint is surprised by my use of this in the following code:

6条回答
  •  甜味超标
    2020-12-03 01:21

    In a strict mode this reference is set to undefined.

    So both your statements will cause reading properties of the undefined object, which will lead to an exception.

    How do I correct my code?

    Remove both those lines.

    UPD: what I state above is how JSLint treats your code, not how I do that.

提交回复
热议问题