Java Script
JavaScript is a scripting language used to create interactive web pages. It runs in the browser and can also run on servers using Node.js.
Primitive:
Number
String
Boolean
Null
Undefined
BigInt
Symbol
Non-Primitive:
Object
Array
Function
| Var | let | const |
| Function scoped | Block scoped | Block scoped |
| Can redeclare | Cannot redeclare | Cannot redeclare |
| Can reassign | Can reassign | Cannot reassign |
| Hoisted | Hoisted | Hoisted |
var a = 10;
let b = 20;
const c = 30;
Hoisting moves variable and function declarations to the top before execution.
console.log(a);
var a = 10;
Output:
undefined
- Checks value only
- Performs type conversion
5 == "5" // true
===
- Checks value and type
5 === "5" // false
Represents an intentional empty value.
let data = null;
Variable declared but not assigned.
let name;
console.log(name);
Output
undefined
Stores multiple values.
let colors = ["Red", "Blue", "Green"];
let fruits = ["Apple", "Orange"];
console.log(fruits[0]);
Output
Apple
Stores data as key-value pairs.
let person = {
name: "Siva",
age: 37
};