JavaScript
Type
MDN
Array
​MDN​
Date
​MDN​
Object
​MDN​
String
​MDN​
JSON
​MDN​
Set
​MDN​
RegExp
​MDN​
Destructuring Assignment
​MDN​
const
​MDN​
let
​MDN​
export
​MDN​

Variable declarations

var
  • function scoped
  • can be redeclared and updated
  • hoisted and initialized with undefined as a value
let
  • block scoped
  • declaring in a for loop, inside an if or in a plain block is not going to let the variable "escape" the block
  • only use let to reassign the variable
  • while let and const are hoisted but not initialized
const
  • immutable
  • block-scoped
  • default to const

Array

Object

Promises

When you go to a restaurant, the hostess gives you a buzzer for your table. When the table is ready, the buzzer buzzes. You respond by sitting at the table.
The buzzer is a promise. It buzzes when the promise resolves, or is ready. The buzz is your handler.
var buzzer = new Promise();
​
fetchTableAsync(hostess => {
var table = hostess.prepareTable();
hostess.informServer();
buzzer.resolve(table);
});
​
buzzer.then(table => me.sitAtTable(table));

Currying

Currying is a process to reduce functions of more than one argument to functions of one argument with the help of lambda calculus.
multiply = (n, m) => (n * m)
multiply(3, 4) === 12 // true
​
curryedMultiply = (n) => ( (m) => multiply(n, m) )
triple = curryedMultiply(3)
triple(4) === 12 // true
Last modified 3yr ago