This is a new technology, part of the ECMAScript 2015 (ES6) standard.
This technology's specification has been finalized, but check the compatibility table for usage and implementation status in various browsers.
values()
메서드는 배열의 각 인덱스에 대한 value를 가지는 새로운 Array Iterator
객체를 반환합니다.
문법
arr.values()
예시
for...of
루프를 통한 반복
var arr = ['w', 'y', 'k', 'o', 'p']; var eArr = arr.values(); // your browser must support for..of loop // and let-scoped variables in for loops for (let letter of eArr) { console.log(letter); }
다른 반복법
var arr = ['w', 'y', 'k', 'o', 'p']; var eArr = arr.values(); console.log(eArr.next().value); // w console.log(eArr.next().value); // y console.log(eArr.next().value); // k console.log(eArr.next().value); // o console.log(eArr.next().value); // p
명세
Specification | Status | Comment |
---|---|---|
ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'Array.prototype.values' in that specification. |
Standard | Initial definition. |
브라우저 호환성
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | Not supported | Not supported | Not supported | Not supported | 9 |
Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | Not supported | Not supported | Not supported | Not supported | Not supported | Not supported |
Firefox에 한정된 내용
- 호환성 문제로 인해, Array.prototype.values()는 현재 SpiderMonkey에서 제거되었습니다.