I made an object which worked fine with FF but resulted in an error with IE (expected identifier, string or number)
var a={text:'abc',class:'def'};
After a litter research, I found class is a reserved word. Quoting the word "class" fixed the problem.
var a={text:'abc',"class":'def'};
Is it recommended to always quote the object name to eliminate these errors?
Thanks
No it's not something that is generally recommended.
What IS recommended is to simply not used reserved words like this. You can quite easily change class to be anything else.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With