Computer programs consist of data and instructions. Data are pieces of information, stored in a particular format. Each programming language has a set of 'types' to which each item of data corresponds.

In Javascript, data can be of the following types


Functions are data too.

This exposes a little bit of one of the most powerful ideas in computer programming - that programs are data too.

This is what enables a style of programming called 'functional programming'.

We say 'functions are first class citizens'.

We can assign functions to variables

let a = () => { console.log("hi") }


Objects are very important in Javascript.

Objects literals are wrapped in curly braces.

Objects consist of "key-value pairs", also called "hash tables" or "hash maps"

This just means that they are a list of pairs of items. In each pair there's a "key", which must be unique within the object and doesn't change. The key is used by other parts of the program to access the other part of the pair, which is the "value".

The value in each key-value pair of an object can itself be any type of data, including a function or another object.

These simple properties make Javascript objects a powerful tool for expressing data structures and "methods" (sets of instructions) to go along with them.

Javascript Objects are the basis for JSON (JavaScript Object Notation) which is now used quite widely for exchanging data between systems. It is very common for web services, and even databases, to return JSON.

You should always edit JSON in a text editor that shows bracket matching :)