We are working on a new version of Javascript.info with updated content and design.

JavaScript: from the Ground to Closures

The aim of this tutorial is to grasp the JavaScript required to build interfaces and really understand what’s going on.

This includes semi-advanced topics like closures, but misses easy topics like “Working with Date and Time”, because they are not strictly required. So we can get to DOM prepared and fast enough.

Mastering data types

  1. String
  2. Number, Math
  3. Array
  4. Objects
  5. Conversion, toString and valueOf

JavaScript has a pack of built-in types. There are strings, numbers, dates, arrays, objects etc.

This section is about main types and their special features.

Functions: declarations and expressions

  1. The syntax
  2. Function Declaration
  3. Function Expression
  4. Function is a value
  5. Running at place
  6. Named function expressions
  7. Function naming
  8. Summary

A function, like a variable, can be defined anywhere in the code.

JavaScript provides several ways of defining them:

  • Function Declaration
  • Function Expression
  • Function as a result of a new Function call

Static variables and methods

  1. Static variables
  2. Static methods

A function is an object. That provides us with a nifty way to create static variables or, in other words, the variables which persist along multiple calls.

Type detection

  1. Typeof operator
    1. Only primitive values
    2. A good use of typeof
    3. A bad use of typeof
  2. [[Class]] to differ between native objects
  3. Checking type for custom objects
  4. Summary

Polymorphic functions is a great concept of programming. That’s a function which treats parameters differently, depending on their type.

To support polimorphism, we need a way to get the type of a variable. There is a small JS zoo here, let’s check it out.

Four scents of "this"

  1. First, when called as a method
  2. Second, when called as a function
  3. Third, in new
  4. Fourth, explicit this
    1. call
    2. apply
  5. Summary

The value of this is dynamic in JavaScript. It is determined when function is called, not when it is declared.


A function decorator accepts a function, wraps (or decorates) it’s call and returns the wrapper, which alters default behavior.

For example, a checkPermissionDecorator decorator may only allow the function to run if the user has enough permissions for that.