Json attribute names why double quotes of personal guesses

  • 2020-03-30 03:36:51
  • OfStack

Reason 1:

More standardized, conducive to analysis

Reason two:

Avoid incompatibility problems caused by keywords such as class

Three reasons:

And perhaps the most obscure:


var a = 00; var b = {00: 12}; a in b; --> true
var a = 0; var b = {'00': 12}; a in b; --> false

My guess is that if the properties of js objects are not of type string, they will be cast first. However, unexpected values may appear in this process. Although this is only an individual case, it is still necessary to form a good habit


Related articles: