Using reserved words as property names, revisited

后端 未结 4 1277
臣服心动
臣服心动 2020-11-28 09:27

Can a reserved word be used as an object\'s property name?

This issue was raised indirectly in a previous Stack Overflow question: Browser support for using a reserv

4条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-28 10:24

    I'm not quite sure what the point is you want to make, so the only answer I can give is: Yes, it's ok to use reserved words as property names.

    (However two small remarks: foo["class"] is ok, not foo[class]. And any way you should be using form.elements["xyz"] and not form.xyz to access an element named xyz.)

提交回复
热议问题