In the case of a property name with quotation marks and no quotation marks are all possible, the effect is the same.
var obj = { name ' Hello ', ' age ' : 1, }; document.write (obj[' name '] + ' <br/> ' ); document.write (obj.age);
The above two lines of code can be executed correctly.
When and only if your property name is an illegal and weird name, you will get an error.
var obj = { 333: ' This will be an error '
document.write (obj.333);
Error at this time.
var obj = { "333": ' This will also be an error ' }; document.write (obj. 333);
If the property name is a number, you must have double quotation marks and access with [] square brackets.
var obj = { "333": ' This is correct '};console.log (obj["333"]);
Conclusion: Using the legal attribute name, using . and [] access are OK;
If the property name is a number, it must be surrounded by "" and accessed with [] square brackets.
An issue in which attribute names are quoted and unquoted when the object is declared by JS