Skip to content Skip to sidebar Skip to footer

Javascript Keywords In Hash Keys

In V8-based JS engines, you can use unquoted keywords in property keys, like ({ delete: 1 }), while in Rhino or other JS engines, it throws an error, how is that possible? What sho

Solution 1:

The new ECMAScript 5 specification allows property names to be reserved words. Some engines might have adopted this new "feature", while others might still require property names to be quoted when they happen to be reserved words.

Solution 2:

For sake of clarity you might want to avoid delete or new or other operators as property names, even while newer specs is relaxed about it

Post a Comment for "Javascript Keywords In Hash Keys"