JavaScript values()
Syntax
The values()
method is a built-in method in JavaScript that returns a new array object containing the values of each element in a given array object, in the order of their occurrence.
The syntax for values()
method is:
array.values()
Example
Here is an example to illustrate the usage of values()
method:
const fruits = ['apple', 'banana', 'orange'];
const fruitValues = fruits.values();
for (let fruit of fruitValues) {
console.log(fruit); // Output: apple, banana, orange
}
Output
The above example will output:
apple
banana
orange