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

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

if (true) {
  var test = true; // use "var" instead of "let"
}

alert(test); // true, the variable lives after if
var are processed at the function start
function sayHi() {
  phrase = "Hello";

  alert(phrase);

  var phrase;
}