JavaScript syntax: Difference between revisions

Content deleted Content added
Mimosveta (talk | contribs)
No edit summary
Variables: update for ES6
Line 75:
 
==Variables==
[[Variable (programming)|Variable]]s in standard JavaScript have no [[Type system|type]] attached, and any value can be stored in any variable. VariablesStarting arewith ES6, the version of the language finalised in 2015, variables can be declared with <code>let</code> (for a mutable variable) or <code>varconst</code> statement(for an immutable one). However, multiplewhile variablesthe canobject assigned to a <code>const</code> cannot be changed, its properties can. Before ES6, variables were declared atwith a <code>var</code> statement; this is still possible, but can cause confusion relating to scoping oncerules. An identifier must start with a letter, underscore (<tt>_</tt>), or dollar sign (<tt>$</tt>); subsequent characters can also be digits (<tt>0-9</tt>). Because JavaScript is case sensitive, letters include the characters "A" through "Z" (uppercase) and the characters "a" through "z" (lowercase).
 
Starting with JavaScript 1.5, [[ISO 8859-1]] or [[Unicode]] letters (or <tt>\uXXXX</tt> Unicode escape sequences) can be used in identifiers.<ref>{{cite web | url=https://developer.mozilla.org/en/JavaScript/Guide/Values,_Variables,_and_Literals&revision=22#Variables | title=Values, Variables, and Literals - MDC | date=16 September 2010 | publisher=Mozilla Developer Network}}</ref> In certain JavaScript implementations, the at sign (@) can be used in an identifier, but this is contrary to the specifications and not supported in newer implementations.