Why aren't ◎ܫ◎ and ☺ valid JavaScript variable names?

前端 未结 4 1442
小蘑菇
小蘑菇 2020-12-04 04:33

I noticed that in Internet Explorer (but, unfortunately, not in the other browsers I tested), you can use some Unicode variable names. This made my day, and I was absolutely

4条回答
  •  死守一世寂寞
    2020-12-04 05:06

    EcmaScript 262, section 7.6 says names must start with $, _, or a Unicode letter, and after that may contain either those characters, or Unicode combining marks, Unicode digits, or Unicode connector punctuation (and a couple of format-control characters that are language specific.)

    So, the difference between allowed and not allowed identifiers in your cases is probably whether the leading character is considered a "letter".

提交回复
热议问题