Headers.entries()
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since March 2017.
Headers.entries()
以迭代器
的形式返回 Headers 对象中所有的键值对。每一对中的键和值都是 String
对象。
备注: 这个方法在 Web Worker 中是可用的。
语法
js
entries()
参数
无。
返回值
返回一个迭代器。
示例
js
// 创建一个测试 Headers 对象
const myHeaders = new Headers();
myHeaders.append("Content-Type", "text/xml");
myHeaders.append("Vary", "Accept-Language");
// 显示键/值对
for (const pair of myHeaders.entries()) {
console.log(`${pair[0]}: ${pair[1]}`);
}
运行结果为:
content-type: text/xml vary: Accept-Language
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
entries |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.