values() method returns an Array Iterator object that contains the value for each element in the array.
values() method does not accept any parameter.
values() method does not change the original array.
values() method iterates empty slots as if they have the value undefined.
The Array iterator object has a built-in method called next() that can be used to get the next value.
const myArray1 = ['a', 'b', 'c'];
const iterator = myArray1.values();
console.log(iterator.next().value);
console.log(iterator.next().value);
console.log(iterator.next().value); returns ↴
a
b
c
Or we can use a for-of loop to iterate over each element in the array ↴
const myArray2 = ['a', 'b', 'c'];
for (let element of myArray2.values())
console.log(element); returns ↴
a
b
c
myArray.values()