JavaScript apply & bind methods

Here is a comparison of the JavaScript apply() and bind() methods: syntax: apply(thisArg, [argsArray]) Calls a function with a given this value and arguments provided as an array (or an array-like object). bind(thisArg, [arg1[, arg2[, …]]]) Creates a new function that, when called, has its this keyword set to the provided value, with a given …

JavaScript apply & bind methods Read More »

JavaScript Maps

A map can store key-value pairs with any data type for the keys. The keys’ original placement order is retained by a Map. Method Description Map() Creates a new Map object. clear() Removes all key/value pairs from the Map object. delete(key) Removes the key/value pair with the specified key. entries() Returns a new Iterator object …

JavaScript Maps Read More »

JavaScript Sets

Sets are the collection which store unique value . Here is a table of the most common methods for JavaScript Set objects: Method Description add(value) Adds a new element to the set delete(value) Removes an element from the set has(value) Returns true if the set contains the specified element, false otherwise clear() Removes all elements from the set …

JavaScript Sets Read More »

JavaScript Object Constructors

A JavaScript object constructor is a function used to create objects from a blueprint/template. The constructor have properties and methods that every object created from it will inherit. Objects are created using the “new” operator. Output: {“firstName”:”John”,”lastName”:”Doe”,”age”:50}

JavaScript Arrow Function

Arrow functions were introduced in ES6. allow us to write shorter function syntax: below demo function is an arrow function returning hello World String. The paragraph div content will be replaced by demo function text. Code Example: output: hello Shri Note: If the function has only one statement, and the statement returns a value, you can remove …

JavaScript Arrow Function Read More »

JavaScript Hoisting

In JavaScript, hoisting is the behavior of moving declarations to the top of their scope. This means that variable and function declarations are processed before any code is executed, regardless of where the declaration is written in the code example code: output: hii Only global variable get hoisted. The let and const keywords were introduced …

JavaScript Hoisting Read More »

JavaScript Switch Case

from JavaScript 1.2 onwards, we can use a switch statement which provide alternative to if statements, and it does better than repeated if…else if statements. Syntax: The expression is evaluated and compared to each case label. If a match is found, the corresponding statement is executed. If no match is found, the defaultStatement (if provided) is executed. The break statement …

JavaScript Switch Case Read More »

Scroll to Top