Headers

Headers.prototype.values

Returns an iterator allowing you to go through all values of the key/value pairs contained in the Headers object

Syntax

JavaScript
headers.values()

Return Value

An iterator of header value strings

Examples

Basic Usage
const headers = new Headers({ 'A': '1', 'B': '2', 'C': '3' })
const values = [...headers.values()]
console.log(values) // ['1', '2', '3']
Practical Example
const res = await fetch('/api/data')
for (const value of res.headers.values()) {
  console.log(value)
}
Advanced Usage
const headers = new Headers()
headers.set('X-Rate-Limit', '100')
headers.set('X-Rate-Remaining', '42')
console.log([...headers.values()])

Understanding Headers.prototype.values

The Headers.prototype.values method in JavaScript returns an iterator allowing you to go through all values of the key/value pairs contained in the Headers object. It belongs to the Headers object and is one of the most widely used methods for working with headers values in modern JavaScript and TypeScript applications.

The method signature is headers.values(). When called, it returns an iterator of header value strings. Understanding when and how to use values() helps you write more expressive, readable code.

Common use cases for Headers.prototype.values include data transformation, input validation, API response processing, and building reusable utility functions. It works well alongside related methods like fetch-headers-keys, fetch-headers-entries, fetch-headers-get, enabling you to chain operations together for complex data manipulation pipelines.

Browser support for Headers.prototype.values is excellent across all modern browsers including Chrome, Firefox, Safari, and Edge. It is also fully supported in Node.js and Deno. For older environments, transpilation with Babel or a polyfill may be needed.

Browser Compatibility

Supported in all modern browsers (Chrome, Firefox, Safari, Edge) and Node.js. Part of the ECMAScript standard.

Related Methods

More Headers Methods

Other methods in the Headers object

Related Tools

More Headers Methods

Explore JavaScript Methods

Browse our complete reference of 410 JavaScript methods with syntax, examples, and explanations.