4 ms·
Which JavaScript property names can be unquoted? When can dot notation be used?
- gf3 15y agoInformative 𝘢𝘯𝘥 how!
- mathias 15y agohttp://mothereff.in/js-properties#%F0%9D%98%A2%F0%9D%98%AF%F0%9D%98%A5 http://mothereff.in/js-properties#%F0%9D%98%A2%F0%9D%98%AF%F... :(
- simcop2387 15y agoOne thing that you might want to keep in mind is that I seem to recall IE 6/7 being funny with quoting here compared to other browsers. Firefox and Chrome behaved like this but earlier IE's I always ran into problems with if I didn't quote everything.
- mathias 15y agoThe ECMAScript spec states that engines are free to choose which Unicode version they support, and that Unicode 3.0 is considered to be the lowest common denominator. Old IEs use an outdated Unicode version (I’d guess Unicode 3.0) to determine whether a given string is a valid identifier name. When using the Unicode 6.1.0 database, much more identifier names are allowed. (More on that here: http://mathiasbynens.be/notes/javascript-identifiers http://mathiasbynens.be/notes/javascript-identifiers & http://mothereff.in/js-variables. http://mothereff.in/js-variables.) Could that be what you’re referring to? Can you give a concrete example of a property name that should be allowed, but fails to work in old IE?
- simcop2387 15y agoPossbily, I'll try to dig up something from my old projects. I wouldn't be surprised if I seem to be misinformed about it a little.
- mathias 15y agoYou may have been thinking of ES3, which disallowed the use of unquoted reserved words as property names. So yeah, quoting is still a good idea, especially if backwards compatibility is a concern.