From 020fe0387283d97d3d42b7d95e0c4e4bb16817df Mon Sep 17 00:00:00 2001 From: Harrison Shoff Date: Wed, 7 Aug 2013 16:08:38 -0700 Subject: [PATCH] [objects] update discussion on reserved word usage. fixes #61 --- README.md | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 609fcb910d..88db16797e 100644 --- a/README.md +++ b/README.md @@ -83,23 +83,40 @@ var item = {}; ``` - - Don't use [reserved words](https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Reserved_Words) as keys. + - Don't use [reserved words](http://es5.github.io/#x7.6.1) as keys. It won't work in IE8. [More info](https://github.com/airbnb/javascript/issues/61) ```javascript // bad var superman = { - class: 'superhero', default: { clark: 'kent' }, private: true }; // good var superman = { - klass: 'superhero', defaults: { clark: 'kent' }, hidden: true }; ``` + + - Use readable synonyms in place of reserved words. + + ```javascript + // bad + var superman = { + class: 'alien' + }; + + // bad + var superman = { + klass: 'alien' + }; + + // good + var superman = { + type: 'alien' + }; + ``` **[[⬆]](#TOC)** ## Arrays