mozilla

Revision 86395 of Values, Variables, and Literals

  • Revision slug: Talk:JavaScript/Guide/Values,_variables,_and_literals
  • Revision title: Values, Variables, and Literals
  • Revision id: 86395
  • Created:
  • Creator: teoli
  • Is current revision? No
  • Comment 24 words added

Revision Content

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

Revision Source

<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%2C_Variables%2C_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="https://developer.mozilla.org/User:teoli" rel="custom nofollow">teoli</a> 05 October 2010</p>
Revert to this revision