Home > Web Front-end > JS Tutorial > Why do json attribute names need double quotes (personal guess)_javascript skills

Why do json attribute names need double quotes (personal guess)_javascript skills

WBOY
Release: 2016-05-16 16:40:34
Original
1302 people have browsed it

Reason 1:

More standardized and easier to analyze

Reason 2:

Avoid incompatibility issues caused by keywords such as class

Reason 3:

Probably the most obscure one:

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

Personally guess that if the attribute name of the js object is non-string type, type conversion will be performed first, but unexpected values ​​may appear in this process. Although this is only an isolated case, it is still very useful to develop a good habit. Necessary

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template