Allowed/recommended property names in object literals in javascript
<p>According to this page <a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Reserved_Words" rel="nofollow">https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Reserved_Words</a></p>

<p>You can't use these reserved words as variables, but can you use them this way apperantly:</p>

<pre><code>var test = {
    break : 'whatever',
    case : 'whatever',
    if : 'whatever',
    in : 'whatever'
    //etc
};
</code></pre>

<p>I have a fiddle here with all the values <a href="http://jsfiddle.net/9RQ9j/4/" rel="nofollow">http://jsfiddle.net/9RQ9j/4/</a></p>

<p>And I get no errors either defining them or calling for instance like this</p>

<pre><code>console.log(test.if)
</code></pre>

<p>So to me it seems possible, but is it in conflict with the javascript spec? Then it seems at least like all the browsers I have tested in (which are most) do violate the spec and allow you to use those words.</p>

<p>(UPDATE: seems to fail in IE 8 + possibly other IE's)</p>

<p>And is it even good practice?</p>

<p>Last question: Is this ok?</p>

<pre><code>var test = {
    'break' : 'whatever',
    'case' : 'whatever',
    'if' : 'whatever',
    'in' : 'whatever'
};
</code></pre>
