Aws
Auth
Axios
Admin
Angular
Android
Atom Payment
BPO
BcryptJs
Bootstrap
Basic Computer
C Language
C++
Css
Canva
Common questions
CorelDraw
Cloudinary
Content Writer
DSA
Django
Error
Excel
ExpressJs
Flutter
Github
Graphql
GoDaddy
HR
Html5
Hostinger
Jwt
Java
Json
Jquery
Javascript
Linux OS
Loopback API
MySQL
Manager
MongoDB
Marketing
MS Office
Mongoose
NodeJs
NextJs
Php
Python
Photoshop
PostgreSQL
PayU Payment
Paypal Payment
Redux
ReactJs
Router
React Native
React Router Dom
React Helmet
Sass
SEO
SMO
Stripe Payment
System Administrator
Software Testing
Typescript
Tailwind
Telesales
Tally
VueJs
Windows OS
XML
What is the `Array.prototype.indexOf` method in JavaScript?
`Array.prototype.indexOf` returns the index of the first occurrence of a specified element within the array. If the element is not found, it returns `-1`. It performs a strict comparison (===). const arr = ['a', 'b', 'c']; console.log(arr.indexOf('b')); // 1 console.log(arr.indexOf('d')); // -1
`Array.prototype.indexOf` returns the index of the first occurrence of a specified element within the array. If the element is not found, it returns `-1`. It performs a strict comparison (===). const arr = ['a', 'b', 'c']; console.log(arr.indexOf('b')); // 1 console.log(arr.indexOf('d')); // -1
What is the `String.prototype.indexOf` method in JavaScript?
`String.prototype.indexOf` returns the index of the first occurrence of a specified value in a string. If the value is not found, it returns -1. const str = 'hello'; const index = str.indexOf('l'); console.log(index); // 2
`String.prototype.indexOf` returns the index of the first occurrence of a specified value in a string. If the value is not found, it returns -1. const str = 'hello'; const index = str.indexOf('l'); console.log(index); // 2
What is the `String.prototype.replace` method in JavaScript?
`String.prototype.replace` replaces the first occurrence of a substring or pattern (regular expression) with a new substring. To replace all occurrences, a global regular expression must be used. const str = 'hello world'; const newStr = str.replace('world', 'JavaScript'); console.log(newStr); // 'hello JavaScript'
`String.prototype.replace` replaces the first occurrence of a substring or pattern (regular expression) with a new substring. To replace all occurrences, a global regular expression must be used. const str = 'hello world'; const newStr = str.replace('world', 'JavaScript'); console.log(newStr); // 'hello JavaScript'
What is the `Array.prototype.find` method in JavaScript?
`Array.prototype.find` returns the first element in the array that satisfies the provided testing function. If no elements satisfy the function, it returns `undefined`. It does not modify the original array. const arr = [1, 2, 3]; const firstEven = arr.find(num => num % 2 === 0); console.log(firstEven); // 2
`Array.prototype.find` returns the first element in the array that satisfies the provided testing function. If no elements satisfy the function, it returns `undefined`. It does not modify the original array. const arr = [1, 2, 3]; const firstEven = arr.find(num => num % 2 === 0); console.log(firstEven); // 2
What is the `Array.prototype.shift` method in JavaScript?
`Array.prototype.shift` removes the first element from an array and returns that element. It modifies the original array and shifts all subsequent elements down by one. const arr = [1, 2, 3]; const first = arr.shift(); console.log(first); // 1 console.log(arr); // [2, 3]
`Array.prototype.shift` removes the first element from an array and returns that element. It modifies the original array and shifts all subsequent elements down by one. const arr = [1, 2, 3]; const first = arr.shift(); console.log(first); // 1 console.log(arr); // [2, 3]
What is the `String.prototype.search` method in JavaScript?
`String.prototype.search` searches a string for a match against a regular expression and returns the index of the first match. If no match is found, it returns -1. const str = 'hello 123'; const index = str.search(/\d+/); console.log(index); // 6
`String.prototype.search` searches a string for a match against a regular expression and returns the index of the first match. If no match is found, it returns -1. const str = 'hello 123'; const index = str.search(/\d+/); console.log(index); // 6
What is the `Array.prototype.flatMap` method in JavaScript?
`Array.prototype.flatMap` maps each element using a provided mapping function and then flattens the resulting array into a new array. It combines the map and flat operations into a single method. const arr = [1, 2, 3]; const flatMapArr = arr.flatMap(x => [x, x * 2]); console.log(flatMapArr); // [1, 2, 2, 4, 3, 6]
`Array.prototype.flatMap` maps each element using a provided mapping function and then flattens the resulting array into a new array. It combines the map and flat operations into a single method. const arr = [1, 2, 3]; const flatMapArr = arr.flatMap(x => [x, x * 2]); console.log(flatMapArr); // [1, 2, 2, 4, 3, 6]
What is the `Array.prototype.findIndex` method in JavaScript?
`Array.prototype.findIndex` returns the index of the first element in the array that satisfies the provided testing function. If no elements satisfy the function, it returns `-1`. It does not modify the original array. const arr = [5, 12, 8]; const index = arr.findIndex(num => num > 10); console.log(index); // 1
`Array.prototype.findIndex` returns the index of the first element in the array that satisfies the provided testing function. If no elements satisfy the function, it returns `-1`. It does not modify the original array. const arr = [5, 12, 8]; const index = arr.findIndex(num => num > 10); console.log(index); // 1
What is the purpose of the VLOOKUP function?
The VLOOKUP function searches for a value in the first column of a table and returns a value from a specified column in the same row. For example, =VLOOKUP('Apple', A1:C10, 2, FALSE) searches for 'Apple' in column A and returns the corresponding value from column B. This function is useful for looking up information in tables.
The VLOOKUP function searches for a value in the first column of a table and returns a value from a specified column in the same row. For example, =VLOOKUP('Apple', A1:C10, 2, FALSE) searches for 'Apple' in column A and returns the corresponding value from column B. This function is useful for looking up information in tables.
Implement Depth-First Search
DFS explores as far as possible along each branch before backtracking. Use a stack or recursion to keep track of nodes. For example, in a graph with nodes 1 -> 2 -> 3, DFS from 1 explores 1, 2, and then 3.
DFS explores as far as possible along each branch before backtracking. Use a stack or recursion to keep track of nodes. For example, in a graph with nodes 1 -> 2 -> 3, DFS from 1 explores 1, 2, and then 3.
Implement Breadth-First Search
BFS explores all neighbors of a node before moving to the next level. Use a queue to keep track of nodes. For example, in a graph with nodes 1 -> 2 -> 3, BFS from 1 explores 1, then 2 and 3.
BFS explores all neighbors of a node before moving to the next level. Use a queue to keep track of nodes. For example, in a graph with nodes 1 -> 2 -> 3, BFS from 1 explores 1, then 2 and 3.
Find the First Non-Repeating Character in a String
Use a hash map to count the frequency of each character, then iterate through the string to find the first character with a count of 1. For example, in 'swiss', the first non-repeating character is 'w'.
Use a hash map to count the frequency of each character, then iterate through the string to find the first character with a count of 1. For example, in 'swiss', the first non-repeating character is 'w'.