values() 方法回傳一個 Iterator 物件,包含著 Set 物件中所有元素,由插入順序排序。

keys() 是這個方法的替身 (為了與 Map 物件保持相似性);他運行的完全一模一樣,回傳 Set 中元素的 values

語法

mySet.values();

回傳值

一個 Iterator 物件,包含著 Set 物件中所有元素,由插入順序排序。

範例

使用 values()

var mySet = new Set();
mySet.add('foo');
mySet.add('bar');
mySet.add('baz');

var setIter = mySet.values();

console.log(setIter.next().value); // "foo"
console.log(setIter.next().value); // "bar"
console.log(setIter.next().value); // "baz"

規範

規範 狀態
ECMAScript 2015 (6th Edition, ECMA-262)
The definition of 'Set.prototype.values' in that specification.
Standard Initial definition.
ECMAScript Latest Draft (ECMA-262)
The definition of 'Set.prototype.values' in that specification.
Draft  

瀏覽器相容性

Update compatibility data on GitHub
DesktopMobileServer
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung InternetNode.js
valuesChrome Full support 38Edge Full support 12Firefox Full support 24IE No support NoOpera Full support 25Safari Full support 8WebView Android Full support 38Chrome Android Full support 38Firefox Android Full support 24Opera Android Full support 25Safari iOS Full support 8Samsung Internet Android Full support Yesnodejs Full support 0.12

Legend

Full support  
Full support
No support  
No support

另見

文件標籤與貢獻者

此頁面的貢獻者: hmysjiang
最近更新: hmysjiang,