JavaScript (JS) is a high-level, interpreted scripting language primarily used to create interactive effects within web browsers. It is one of the core technologies of the World Wide Web, alongside HTML and CSS.
✅ JavaScript Reference Table
🔹 1. JavaScript Keywords
| Keyword | Description |
|---|---|
| break | Exits a loop or switch statement |
| case | Defines a case in a switch statement |
| catch | Defines a block to handle errors |
| class | Declares a class (ES6) |
| const | Declares a block-scoped constant |
| continue | Skips current loop iteration |
| debugger | Stops execution for debugging |
| default | Defines default block in switch |
| delete | Deletes a property from an object |
| do | Starts a do...while loop |
| else | Defines the false path of if statement |
| export | Exports functions/variables (ES6 Modules) |
| extends | Inherit class from another (OOP) |
| finally | Executes after try/catch block |
| for | Begins a for loop |
| function | Declares a function |
| if | Executes if a condition is true |
| import | Imports modules (ES6) |
| in | Checks if property exists in object |
| instanceof | Checks if object is an instance |
| let | Declares a block-scoped variable |
| new | Creates an instance of object/class |
| null | Represents null or "nothing" |
| return | Exits from a function and returns a value |
| super | Refers to parent class |
| switch | Conditional branching with multiple cases |
| this | Refers to current object |
| throw | Throws an exception |
| try | Defines block to test for errors |
| typeof | Returns variable type as string |
| var | Declares a variable |
| void | Evaluates an expression without returning |
| while | Starts a while loop |
| with | Extends scope chain |
| yield | Pauses/resumes generator function |
🔹 2. JavaScript Data Types
| Type | Example |
|---|---|
| String | "Hello World" |
| Number | 42, 3.14 |
| Boolean | true, false |
| Undefined | Variable declared but not assigned |
| Null | null |
| Object | { name: "John", age: 25 } |
| Array | [1, 2, 3] |
| Function | function() {} |
| Symbol | Symbol("id") |
| BigInt | 12345678901234567890n |
🔹 3. JavaScript Operators
✅ Arithmetic Operators
| Operator | Description | Example |
|---|---|---|
| + | Addition | a + b |
| - | Subtraction | a - b |
| * | Multiplication | a * b |
| / | Division | a / b |
| % | Modulus (Remainder) | a % b |
| ** | Exponentiation | a ** b |
| ++ | Increment | a++ |
| -- | Decrement | a-- |
✅ Assignment Operators
| Operator | Description |
|---|---|
| = | Assign |
| += | Add and assign |
| -= | Subtract and assign |
| *= | Multiply and assign |
| /= | Divide and assign |
| %= | Modulus and assign |
✅ Comparison Operators
| Operator | Description |
|---|---|
| == | Equal |
| === | Strict equal (value + type) |
| != | Not equal |
| !== | Strict not equal |
| > | Greater than |
| < | Less than |
| >= | Greater or equal |
| <= | Less or equal |
✅ Logical Operators
| Operator | Description |
|---|---|
| && | Logical AND |
| || | Logical OR |
| ! | Logical NOT |
🔹 4. Control Structures
| Structure | Description |
|---|---|
| if...else | Conditional execution |
| switch | Multi-branch selection |
| for | Loop with counter |
| while | Loop with condition |
| do...while | Loop at least once |
| break | Exit loop |
| continue | Skip current iteration |
🔹 5. DOM Tags/Methods
| Method / Property | Description |
|---|---|
| document.getElementById() | Selects element by ID |
| document.querySelector() | Selects first matching element |
| innerHTML | Gets/sets HTML content |
| textContent | Gets/sets text content |
| classList.add() | Adds a class |
| classList.remove() | Removes a class |
| createElement() | Creates an HTML element |
| appendChild() | Appends child element |
| addEventListener() | Adds event to an element |
🔹 6. Common Built-in Functions
| Function | Description |
|---|---|
| alert() | Shows popup alert |
| console.log() | Outputs message to console |
| parseInt() | Converts string to integer |
| parseFloat() | Converts string to float |
| isNaN() | Checks if value is NaN |
| typeof | Returns data type |
| JSON.stringify() | Converts object to JSON string |
| JSON.parse() | Converts JSON string to object |
Click to go back on notes page.