Last Updated: February 25, 2017
· szymonkor

Re-introduction to JS

Interesting article:

A little bit too much of ES5 for an experienced developer.

JavaScript types

  • Number
  • String
  • Boolean
  • Symbol (new in ES2015)
  • Object (Function, Array, Date, RegExp)
  • null
  • undefined


There are no integers in JS.
In practice, integer values are treated as 32-bit ints, and some implementations even store it that way until they are asked to perform an instruction that's valid on a Number but not on a 32-bit integer. This can be important for bit-wise operations.

Converting String to number: parseInt (use usually 10 as a second argument) or parseFloat. Or you can also use the unary + operator to convert values to numbers: + "10". Nice.

Fun parts:

  • NaN (check with isNaN)
  • Infinity or -Infinity (isFinite)


More accurately, they are sequences of UTF-16 code units; each code unit is represented by a 16-bit number. Each Unicode character is represented by either 1 or 2 code units.
No more fun knowledge this time.


  • false, 0, empty strings (""), NaN, null, and undefined all become false.
  • All other values become true.


let allows you to declare block-level variables. The declared variable is available from the function block it is enclosed in. My name was featured in the article <3

const allows you to declare variables whose values are never intended to change. The variable is available from the function block it is declared in.

const Pi = 3.14; // variable Pi is set
Pi = 1; // will throw an error because you cannot change a constant variable.

var is the most common declarative keyword. It does not have the restrictions that the other two keywords have. This is because it was traditionally the only way to declare a variable in JavaScript. A variable declared with the var keyword is available from the function block it is declared in.


JavaScript's numeric operators are +, -, *, / and % — which is the remainder operator (which is not the same as modulo.) Values are assigned using =, and there are also compound assignment statements such as += and -=. These extend out to x = x operator y.

If you add a string to a number (or other value) everything is converted in to a string first. This might catch you up:

Control structures

  • while
  • do .. while
  • for(let value of array)
  • for(let property in object)


Remember — the length of the array is one more than the highest index.