JavaScript Language
Table of Contents
for reference
outer: for (let i = 0; i < 3; i++) {
for (let j = 0; j < 3; j++) {
let input = prompt(`Value at coords (${i},${j})`, '');
// if an empty string or canceled, then break out of both loops
if (!input) break outer; // (*)
// do something with the value...
}
}
alert('Done!');switch reference
- The value of
xis checked for a strict equality
switch(x) {
case 'value1': // if (x === 'value1')
...
[break]
case 'value2': // if (x === 'value2')
...
[break]
default:
...
[break]
}What and Why should I use 'use strict';? discussion
Strict mode is declared by adding 'use strict'; to the beginning of a script or a function. Always use it. It's a kind of modern mode
let vs const vs var discussion
letandconstbehave exactly the same way in terms of Lexical Environments.varhas no block scope ::
if (true) {
var test = true; // use "var" instead of "let"
}
alert(test); // true, the variable lives after ifvarare processed at the function start