mozilla

Revision 86396 of Values, Variables, and Literals

  • Revision slug: Talk:JavaScript/Guide/Values,_variables,_and_literals
  • Revision title: Values, Variables, and Literals
  • Revision id: 86396
  • Created:
  • Creator: Manuel Strehl
  • Is current revision? No
  • Comment 53 words added

Revision Content

I think the definition of "Object Literals" got removed erroneously. The anchor tag for it does not work now.

Now "Boolean Literals" exists at two places. This happened after the edit on 18-Jun-2012.

Can it be corrected?

Thanks,

GBh

====

I guess that the concept about what the var keyword does is quite wrong. There say that var "declares" a variable, and conceptually this keyword just binds a variable to the current scope. var is designed for scope bounding, not for declaring variables. Indeed, all variables in JavaScript are implicit and they're placed in the global scope by default, that's because it's so important to use var to bound a variable to a scope (even if we want to bound a variable to the global scope).

Could it be reviewed?

Thanks,

Matías

====

Yes, but isn't it already explained there ?
Both explanations seem the same to me.
teoli 05 October 2010

---

About the var keyword: I noticed, that both

 var b = a, a = "foo";

and

 var a = "foo", b = a;

produce an b == "foo". Any ideas, which one is canonical, or are both correct?

Manuel

Revision Source

<p>I think the definition of "Object Literals" got removed erroneously. The anchor tag for it does not work now.</p>
<p>Now "Boolean Literals" exists at two places. This happened after the edit on 18-Jun-2012.</p>
<p>Can it be corrected?</p>
<p>Thanks,</p>
<p>GBh</p>
<p>====</p>
<p>I guess that the concept about what the <em>var</em> keyword does is quite wrong. There say that var "declares" a variable, and conceptually this keyword just binds a variable to the current scope. var is designed for scope bounding, not for declaring variables. Indeed, all variables in JavaScript are implicit and they're placed in the global scope by default, that's because it's so important to use var to bound a variable to a scope (even if we want to bound a variable to the global scope).</p>
<p>Could it be reviewed?</p>
<p>Thanks,</p>
<p>Matías</p>
<p>====</p>
<p>Yes, but isn't it already explained <a href="/en/JavaScript/Guide/Values,_variables,_and_literals#Variable_Scope" title="https://developer.mozilla.org/en/JavaScript/Guide/Values,_Variables,_and_Literals#Variable_Scope">there</a> ?<br> Both explanations seem the same to me.<br> <a href="/User:teoli" rel="custom nofollow">teoli</a> 05 October 2010</p>
<p>---</p>
<p>About the var keyword: I noticed, that both</p>
<p> var b = a, a = "foo";</p>
<p>and</p>
<p> var a = "foo", b = a;</p>
<p>produce an b == "foo". Any ideas, which one is canonical, or are both correct?</p>
<p>Manuel</p>
Revert to this revision