Is 'event' a reserved word in JavaScript?

前端 未结 6 1888
谎友^
谎友^ 2020-12-09 01:47

I am a beginner to Javascript. And when I was practicing I have noticed something.

Take this function:



        
6条回答
  •  渐次进展
    2020-12-09 02:18

    This is old, but since I stumbled over it I figure I might as well answer.

    http://www.w3schools.com/js/js_reserved.asp says that event is NOT a reserved word, as mentioned in the comments above. However, if you read further down the page....

    "Windows Reserved Words JavaScript can be used outside HTML. It can be used as the programming language in many other applications.

    In HTML you must (for portability you should) avoid using the name of HTML and Windows objects and properties:"

    And 'event' is displayed in the table below. So can you use it? Sure. Should you use it? No. There are heaps of examples on stackoverflow that use event, but they're using it for clarity. When you use that code, you need to edit it.

提交回复
热议问题