Part 6–100 Advanced JavaScript Interview Questions with Answers and Code Examples
Welcome to the sixth part of our series on advanced JavaScript interview questions!
Introduction:
In this article, we’ll continue to explore ten more challenging questions that will test your knowledge of JavaScript concepts and techniques. Each question is accompanied by a detailed answer and code examples to help you understand the topic thoroughly. Additionally, we’ll provide external links for further reading to enhance your understanding. Let’s dive in!
51- What is the purpose of the “some()” method in JavaScript arrays? Provide an example.
Answer: The some()
method tests whether at least one element in the array passes the provided testing function. It returns true
if any element satisfies the condition; otherwise, it returns false
. Here's an example:
const numbers = [1, 2, 3, 4, 5];
const isEven = (number) => number % 2 === 0;
const hasEvenNumber = numbers.some(isEven);
console.log(hasEvenNumber); // Output: true
Further Reading: MDN Web Docs — Array.prototype.some()