The variety of data types that a programming language offers is one of its most fundamental features. These are the kind of values that a programming language can represent and modify. Strings (wrapped in single or double quotes), numbers, big ints, Booleans (a value that is true or false), null, undefined, objects, and symbols are just a few of the data types available in JavaScript.

Variables

let name = "The Web";
const galaxy = "Milky Way";
var age = 100;
name = "Nebula"; // let and var can be reassigned

Variables are data storage containers. Name, galaxy, and age are variables in this example, and they are declared with the keywords let, const, and var. Variable names can contain letters, numerals, underscores, and dollar signs, and they must be unique. A letter, a dollar symbol ($), or an underscore (_) must be the first character in a name. The equal symbol (=) in JavaScript is an "assignment" operator, not an "equal to" operator.

More on variables

var name = "Linc";
var age = 120;
var bool = true;
var arr= ["The", "Web"];
arr[0]; // returns "The"arr[1] = "The"; 
// arr is now ["The", "The"]
var obj = {name: "The", age:100};
obj.age; // returns 100

name is a string variable, age is a number, bool is a boolean, arr is an indexed array with zero as the index or position of the first item, and obj is an object with a key and a value.

Operators

Arithmetic Operators - add(+), subtract(-), multiply(*),divide(/)

Comparison Operators - equal to(==), not equal to(!=), greater than or equal to(>=), less than equal to(<=), greater than(>), less than(<)

Logical Operators - and (&&), or(||), not(!)

Arrays

var arr= [1, 2, 3];
// or
var arr = new Array(1, 2, 3);
arr[1] = 10; // returns [1, 10, 3]
arr[0] // returns 1

An Array object in JavaScript can store a list of variables. Use the [] or the Array object notation to define an array. To address a specific cell in an array, we can use the brackets [] operator. Because zero-based indices are used in addressing, the second component of myArray can be addressed with index 1. You can store components of multiple types in the same array since JavaScript Arrays are essentially special sorts of objects.

Objects

var obj = {name : "The Web", age : 100}
obj.age // returns 100
obj["galaxy"] = "Milky Way"; // obj is {name: "The", age: 100; galaxy: "Milky Way"}

Members of objects are addressed using the brackets operator [} similar to arrays, but the period (.) operator can also be used, like in many other object-oriented languages. Except for the fact that brackets return a member using a string, but the period operator needs the member to be a plain word, they are quite similar (the word should not contain spaces, start with a number or use illegal characters).

Statement

if(condition){  
	//code
}else if(another condition){  
	//code
}else{  
	//code
}

The conditional statements in JavaScript are as follows: