Modern JavaScript: Difference between revisions
Jump to navigation
Jump to search
Created page with "== Defining variables == * Do not use <code>var</code> - it is not scoped to blocks (effectively it is a global variable) and it can be redefined * Use <code>const</code> for values which should not change (remember that properties of the object *can* change, even though the object pointed to cannot) * Use <code>let</code> for values which may change" |
No edit summary |
||
Line 2: | Line 2: | ||
* Do not use <code>var</code> - it is not scoped to blocks (effectively it is a global variable) and it can be redefined | * Do not use <code>var</code> - it is not scoped to blocks (effectively it is a global variable) and it can be redefined | ||
* Use <code>const</code> for values which | * Use <code>const</code> for values which must not change and which can be set on initialisation (remember that properties of the object *can* change, even though the object pointed to cannot) | ||
* Use <code>let</code> for values which may change | * Use <code>let</code> for values which may change |
Latest revision as of 15:57, 24 October 2022
Defining variables
- Do not use
var
- it is not scoped to blocks (effectively it is a global variable) and it can be redefined - Use
const
for values which must not change and which can be set on initialisation (remember that properties of the object *can* change, even though the object pointed to cannot) - Use
let
for values which may change