We're looking for a user researcher to understand the needs of developers and designers. Is this you or someone you know? Check out the post: https://mzl.la/2IGzdXS

Headers.entries()

这是一个实验中的功能
此功能某些浏览器尚在开发中,请参考浏览器兼容性表格以得到在不同浏览器中适合使用的前缀。由于该功能对应的标准文档可能被重新修订,所以在未来版本的浏览器中该功能的语法和行为可能随之改变。

Headers.entries() 以 迭代器 的形式返回Headers对象中所有的键值对. 

Note: 这个方法在 Web Workers中是可用的.

Syntax

headers.entries();

Return value

返回一个 迭代器.

Example

// Create a test Headers object
var myHeaders = new Headers();
myHeaders.append('Content-Type', 'text/xml');
myHeaders.append('Vary', 'Accept-Language');

// Display the key/value pairs
for (var pair of myHeaders.entries()) {
   console.log(pair[0]+ ': '+ pair[1]);
}

返回结果:

content-type: text/xml
vary: Accept-Language

Specifications

Specification Status Comment
Fetch
Headers.entries() (as iterator<>)
Living Standard Initial definition.

Browser compatibility

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support ? 44 (44) ? ? ?
Feature Android Chrome for Android Firefox Mobile (Gecko) Firefox OS (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support ? ? 44.0 (44) (Yes) ? ? ?

See also

文档标签和贡献者

此页面的贡献者: Taoja
最后编辑者: Taoja,