When parsing Javascript, what determines the meaning of a slash?

后端 未结 5 1406
清歌不尽
清歌不尽 2020-12-01 07:43

Javascript has a tricky grammar to parse. Forward-slashes can mean a number of different things: division operator, regular expression literal, comment introducer, or line-

5条回答
  •  天命终不由人
    2020-12-01 08:14

    JSLint appears to expect a regular expression if the preceding token is one of

    (,=:[!&|?{};
    

    Rhino always returns a DIV token from the lexer.

提交回复
热议问题