Part 1 - #4/35+ Array.entries() | JavaScript Array Methods | Interview Questions and Answers

preview_player
Показать описание
The entries() method is a built-in method in JavaScript that is used with arrays (and other iterable objects like Map and Set). It returns a new Array Iterator object that contains key-value pairs for each index in the array, where the key is the index and the value is the element at that index.

let fruits = ['Apple', 'Banana', 'Cherry'];

for (let entry of iterator) {
}
[0, 'Apple']
[1, 'Banana']
[2, 'Cherry']

Important Points:
The entries() method does not modify the array; it just provides an iterator.

#generalknowledge #codinginterviewquestions #gk #javacodinginterview #interviewquestions #quiz
Рекомендации по теме