BonsaiDen / JavaScript-Garden

A collection of documentation about the most quirky parts of the JavaScript language.
http://bonsaiden.github.com/JavaScript-Garden
MIT License
3.45k stars 558 forks source link

No quotes in object keys #315

Closed MykytaLiashenko closed 8 years ago

MykytaLiashenko commented 8 years ago

You wrote that if you write object in such way: var obj = { 'option': 'This is template string', new_option : 'This is another template' } there will be Syntax error on new_option line, cause you should put it inside quotes. In modern JavaScript, you can write without quotes and it won't be any error. Saw this in Russian localisation.

timruffles commented 8 years ago

Thanks! Please include this in a PR and we'll merge.

lewisje commented 8 years ago

The relevant section must have changed, but new_option is a valid variable identifier, so it can be an unquoted property key even in older engines.