Difference in local storage and session storage?
localStorage and sessionStorage are both web storage options provided by modern web browsers to store data on the client side (in the user’s browser) without relying on cookies. They are…
Pure Component in ReactJS
In React.js, a “pure component” refers to a specific type of component that aims to optimize rendering performance by automatically implementing the shouldComponentUpdate method. This method determines whether a component…
call, apply and bind
call, apply, and bind are three methods available in JavaScript that are used to manipulate the this value and call functions in different ways. They are often used to control…
Javascript Var Datatype Example:
var a= ‘amit’;var b=a; function abc(){console.log(‘in a1 :’,a)var a = ‘Mohit’;console.log(‘in a2 :’,a)}b =’sumit’abc(a);console.log(‘a’,a)console.log(‘b’,b) Output: It looks like you’ve provided a JavaScript code snippet. Let’s break down what’s happening step…
Find Substring
//check a string has substring or notconst str = ‘Har har Modi,Ghar-Ghar Modi.’;const sub_str = ‘Modi’;console.log(‘Is string has a substring? ‘,str.includes(sub_str))// this is case senstive //Get first index of a…
Get Sum of Array Element
//Get Sum of Fruites from Array Element const fruites = [{‘apple’:4,’mango’:7,’banana’:10},{‘apple’:7,’mango’:2,’banana’:11},{‘apple’:1,’mango’:6,’banana’:14},];let cnt = [];fruites.forEach((v)=>{for(key in v){cnt[key]= (cnt[key]+v[key]) || v[key];}})console.log(‘v’,cnt)
Difference in map, filter and reduce array function in Javascript
In JavaScript, map, filter, and reduce are array functions used to perform transformations on arrays. Each of these functions serves a different purpose: Syntax: Example: Syntax: Example: Syntax: Example: In…
Some Interview Questions
How can optimize mysql query? Optimizing MySQL queries is essential for improving the performance and efficiency of your database. Here are some tips to optimize your MySQL queries: Always test…
Display All PHP Errors: Basic & Advanced Usage
Quickly Show All PHP Errors The quickest way to display all php errors and warnings is to add these lines to your PHP code file: ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL);