× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

Object declarations: Do strings as keys make a difference?

Feb 26, 2015
<p>No difference, except that the 2nd one will add two extra <code>"</code> characters in your code which will cost you two extra bytes.</p> <p>And the reason the two types of declaring object properties <code>with or without quotes is because</code> You can try,</p> <pre><code>var obj = {"key Name" : "value"}; </code></pre> <p>and still access it as</p> <pre><code>obj['key Name'] </code></pre> <p>But not</p> <pre><code>var obj = {key Name : "value"}; </code></pre> <p>Thinking this way, there is a difference</p> <p>This tip was originally posted on <a href="http://stackoverflow.com/questions/26017571/Object%20declarations:%20Do%20strings%20as%20keys%20make%20a%20difference?/26017647">Stack Overflow</a>.</p>
comments powered by Disqus