JavaScript

JavaScript is the programming language of HTML and the Web.

JS logo.

Variables

A JavaScript variable is simply a name of storage location. JavaScript uses reserved keyword var to declare a variable. A variable must have a unique name. You can assign a value to a variable using equal to (=) operator when you declare it or before using it.

Conditions

While writing a program, there may be a situation when you need to adopt one out of a given set of paths. In such cases, you need to use conditional statements that allow your program to make correct decisions and perform right actions. JavaScript supports conditional statements which are used to perform different actions based on different conditions.

Functions

A function eliminates the need of writing the same code again and again. Define a function with a unique function name, a list of parameters (that might be empty), and a statement block surrounded by curly braces. To invoke a function somewhere later in the script, you need to write the name of that function.

Loops

Loops are handy, if you want to run the same code over and over again, each time with a different value. Often this is the case when working with arrays. The while loop loops through a block of code as long as a specified condition is true.

Arrays

JavaScript arrays are used to store multiple values in a single variable. An array is a special variable, which can hold more than one value at a time.

Objects

JavaScript objects are containers for named values called properties or methods. Objects are variables too. But objects can contain many values. This code assigns many values (Fiat, 500, white) to a variable named car.