JavaScript Array values() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Array

Definition

Array.prototype.values() returns a new Array Iterator that yields each element value from start to end. It does not copy the array or run a callback. On arrays, for...of uses the same idea via Symbol.iterator.

Remember
array.values()  →  iterator of element values

values()  → apple, orange, banana
keys()    → 0, 1, 2
entries() → [0, "apple"], …

for (const v of arr)  ≈  for (const v of arr.values())
does not mutate the array
lazy — yields one value at a time

Syntax

Call array.values. Start with this line.

JavaScript
array.values()
CallWhat it does
array.values()Primary signature.
array.values(...)Call with the arguments your case needs.

Built into JavaScript. Call values(...) on an array instance — no import required.

Library declarations
JavaScript
array.values()

Parameters

ParameterDescription
Receiver arrayRequired. Source of element values

Return Value

Return ValueDescription
*New Array Iterator (not an array)

JavaScript Examples

Example 1 — Basic values() Loop

Get an iterator and walk every element value.

JavaScript
const fruits = ["apple", "orange", "banana"];
const iterator = fruits.values();

for (const fruit of iterator) {
  console.log(fruit);
}
Try It Yourself

How It Works

  1. Create the array. Three fruit strings.
  2. Call values(). Returns a fresh iterator—not a new array.
  3. Loop with for...of. Each step yields the next element.
  4. Original stays intact. Iteration only reads values.

Example 2 — for...of on the Array

On arrays, looping the array itself yields the same values.

JavaScript
const fruits = ["apple", "orange", "banana"];

for (const fruit of fruits) {
  console.log(fruit);
}
Try It Yourself

How It Works

  1. Same fruits array. No explicit values() call.
  2. for...of uses the default iterator. For arrays, that yields values.
  3. Same output. Equivalent to for (const fruit of fruits.values()).
  4. When to call values()? When you want the iterator object itself (spread, pass around, contrast with keys/entries).

Example 3 — Spread into a New Array

Consume the iterator to build a shallow copy.

JavaScript
const nums = [10, 20, 30];
const copy = [...nums.values()];

console.log(copy);
console.log(copy === nums);  // false
Try It Yourself

How It Works

  1. Start with nums. Three numbers in one array.
  2. Spread the iterator. [...nums.values()] pulls every value into a new array.
  3. Contents match. Elements are the same; object identity is not.
  4. Simpler copy? [...nums] or nums.slice() is more common day to day.

Browser & Runtime Support

Array.prototype.values() is part of ES2015 (ES6). It is available in evergreen browsers and Node.js.

✓ Baseline · ES2015

Array.prototype.values()

Supported in Chrome 45+, Firefox 27+, Safari 9+, Edge (all versions), and Node.js 0.12+. Not supported in Internet Explorer.

98% Modern browser support
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
Array.values() Excellent

Bottom line: Safe for modern web apps and Node LTS. For IE11, feature-detect with if ("values" in Array.prototype) or use a classic index loop / forEach.

Frequently Asked Questions

values() returns a new Array Iterator. Each step yields the next element value from index 0 through length − 1, including undefined for empty slots in sparse arrays.
No. values() only creates an iterator over existing elements. Looping does not change the array.
For arrays, yes. Array.prototype[Symbol.iterator] returns the same kind of iterator as values(), so for (const v of arr) behaves like for (const v of arr.values()).
values() yields each element only. entries() yields [index, value] pairs. Use values() when you do not need indexes.
forEach() runs a callback immediately and returns undefined. values() returns a lazy iterator you can loop, spread ([...arr.values()]), or pass to utilities.
values() is an ES2015 (ES6) feature. All modern browsers and Node.js support it; Internet Explorer does not.

Next: valueOf()

See why valueOf() returns the same array object—not a string or a clone.

valueOf() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

11 people found this page helpful