Are there legitimate uses for JavaScript's “with” statement?

后端 未结 30 2354
伪装坚强ぢ
伪装坚强ぢ 2020-11-22 04:22

Alan Storm\'s comments in response to my answer regarding the with statement got me thinking. I\'ve seldom found a reason to use this particular language feature, and had ne

30条回答
  •  野的像风
    2020-11-22 05:26

    Using with is not recommended, and is forbidden in ECMAScript 5 strict mode. The recommended alternative is to assign the object whose properties you want to access to a temporary variable.

    Source: Mozilla.org

提交回复
热议问题