JavaScript Concepts

Variables

var
This is a public variable to be used everywhere (e.g., var x = 10;).
let
A block-scoped variable, usually for temporary values (e.g., let name = 'John';).
const
A constant variable that cannot be reassigned (e.g., const PI = 3.14;).

Operators

+
Addition operator, used to add numbers or concatenate strings (e.g., 10 + 5 or 'Hello' + ' ' + 'World').
-
Subtraction operator, used to subtract numbers (e.g., 10 - 5).
*
Multiplication operator, used to multiply numbers (e.g., 10 * 5).
/
Division operator, used to divide numbers (e.g., 10 / 5).
==
Equality operator, used to compare values (e.g., 5 == '5').
===
Strict equality operator, compares values and their types (e.g., 5 === '5' is false).

Functions

Function Declaration
A named function that can be called (e.g., function greet() { console.log('Hello'); }).
Function Expression
A function assigned to a variable (e.g., const greet = function() { console.log('Hello'); };).
Arrow Function
A concise way to write functions (e.g., const greet = () => { console.log('Hello'); };).

Arrays

Array Declaration
Arrays are ordered collections (e.g., let arr = [1, 2, 3];).
Array Method - push
Adds an element to the end of the array (e.g., arr.push(4);).
Array Method - pop
Removes the last element of the array (e.g., arr.pop();).
Array Method - map
Creates a new array by applying a function to each element (e.g., arr.map(x => x * 2);).
Array Method - filter
Creates a new array with elements that pass a test (e.g., arr.filter(x => x > 2);).

Loops

for
A basic loop for iterating over arrays or numbers (e.g., for(let i = 0; i < 5; i++) { console.log(i); }).
while
A loop that runs while a condition is true (e.g., while (x < 5) { x++; }).
forEach
An array method that executes a function for each item in the array (e.g., arr.forEach(x => console.log(x));).

Conditionals

if
Executes code based on a condition (e.g., if (x > 5) { console.log('Greater'); }).
else
Provides an alternative condition (e.g., if (x > 5) { } else { }).
switch
Tests multiple conditions (e.g., switch(x) { case 1: break; }).

Objects

Object Literal
An object is a collection of key-value pairs (e.g., let person = { name: 'John', age: 30 };).
Access Object Property
Accessing a property of an object (e.g., person.name).
Object Method
An object can also contain functions (e.g., let person = { greet: function() { console.log('Hello'); } }).