JS Cheat Sheet pdf
JS cheat sheet pdf file is attached here and the key features are:
Data Types and Variables
- String: This represents textual data enclosed within quotation marks.
- Number: Handles numeric values.
- Boolean: Stores true or false values.
- Array: Organizes collections of data in an ordered manner.
- Object: Represents data structures containing key-value pairs.
- Undefined: Signifies the absence of an assigned value.
- Null: Denotes the intentional absence of any object or value.
Arithmetic Operators: Arithmetic operators perform mathematical operations like addition (+), subtraction (-), multiplication (*), division (/), and modulus (%).
Comparison Operators: Comparison operators are used to compare values and determine their relationship. Common comparison operators include equality (==), strict equality (===), inequality (!=), strict inequality (!==), and greater than (>), among others.
Assignment Operators: Assignment operators are employed to assign values to variables. Common assignment operators include the assignment operator (=), addition assignment (+=), and subtraction assignment (-=).
The Switch Statement: The switch statement is another conditional statement that simplifies complex branching logic. It evaluates an expression and executes a block of code based on the value of that expression.
Using Break and Continue: To exit a loop prematurely, use the break statement. On the other hand, the continue statement skips the current iteration and moves to the next one within the loop.
Function Parameters and Return Values: Function parameters are placeholders for values that the function expects as input. Functions can also return values, which represent the output or result of the function’s operation.
Accessing and Modifying Array Elements: Arrays are zero-indexed, meaning the first element is accessed with an index of 0. You can access and modify array elements using square brackets and their corresponding indices.
- push(): This method adds one or more elements to the end of an array.
- pop(): This method removes and returns the last element of an array.
- shift(): This method removes and returns the first element of an array.
- unshift(): This method adds one or more elements to the beginning of an array.
- splice(): This method adds or removes elements from an array at specified positions.
Properties of Objects: Objects consist of properties, which are key-value pairs. You can access properties using dot notation (e.g., objectName.propertyName) or bracket notation (e.g., objectName[‘propertyName’]).
Methods in Objects: Objects can also possess methods, associating functions with the object. Methods that allow objects to perform actions and calculations.
Scope and Closures