JavaScript Hoisting :1. Functions, variables, and class definitions are hoisted to the top.2. let and const are initialized only after they are used.3. The most important concepts in JavaScript.4. To avoid bugs, always declare all variables at the beginning of every sco...
Showing posts with label Javascript. Show all posts
Showing posts with label Javascript. Show all posts
Tuesday, 21 January 2025
Monday, 20 January 2025
undefined
undefined
JavaScript Pure and Impure Functions.1. JavaScript Pure Functions. JavaScript Pure Function Without modifying value return. like predictable out value.function add(x) { return x + 1;}console.log(add(10)); // output : 11console.log(add(11)); // output : 12console.log(add(12)); // output...
undefined
undefined
JavaScript Spread and Rest Operators.1. JavaScript Spread Operator. JavaScript spread operator used for modifying or merging array. let a = [1,2,3,3];let b = [4,5,6,7,3];let output = [...a, ...b];console.log('output--->', output);// output : output---> [1, 2, 3, 3, 4, 5,...
undefined
undefined
JavaScript Closures, Callbacks and Callback Hell, Currying Function.1. JavaScript Closures. Closures is the combination of a bundled function. Closures gives you access to an outer function's scope from an inner function.function init() { var name = 'Mozilla'; function...
Saturday, 18 January 2025
undefined
undefined
Javascript small practical interview questions and answers.
1. Reverse string JavaScript.
let name = "Ankit";let revName = name.split("").reverse().join("");console.log("revName---->", revName); // output : revName----> tiknA
let revNames = "";for(let i = name.length-1; i >= 0; i--) { revNames...
Thursday, 19 December 2024
undefined
undefined
Differences : Map and Foreach Javascript.
Map :
1. map does not modify the original array. 2. map returns a new array with the results of the callback function. const numbers = [1, 2, 3, 4, 5];const squaredNumbers = numbers.map(number => number * number);console.log(squaredNumbers); // Output:...
undefined
undefined
Key Differences : Fetch vs Async/Await
Fetch :
1. simple tasks use this fetch. 2. Uses with .then and .catch 3. fetch is a modern JavaScript API used to make HTTP requests. It returns a Promise that resolves to the Response object representing the response to the request.4. Fetch it returns a Promise.fetch('https://api.example.com/data') ...
undefined
undefined
Event bubbling & capturing in Javascript.
Event bubbling : The event starts at the target element and propagates (bubbles) upward through its ancestors in the DOM hierarchy.
Event Capturing : The event starts from the root element and propagates downward to the target element.
<!DOCTYPE html><html lang="en"><head> ...