Reflect.ownKeys()
정적 메서드는 대상 객체의 자체 속성 키를 배열로 반환합니다.
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
구문
Reflect.ownKeys(target)
매개변수
target
- 자체 키를 가져올 대상 객체.
반환 값
주어진 객체의 자체 속성 키를 담은 Array
.
예외
설명
The Reflect.ownKeys()
메서드는 대상 객체의 자체 속성 키를 배열로 반환합니다. 반환 값은 Object.getOwnPropertyNames(target).concat(Object.getOwnPropertySymbols(target))
와 동일합니다.
예제
Reflect.ownKeys() 사용하기
Reflect.ownKeys({z: 3, y: 2, x: 1}); // [ "z", "y", "x" ]
Reflect.ownKeys([]); // ["length"]
var sym = Symbol.for('comet');
var sym2 = Symbol.for('meteor');
var obj = {[sym]: 0, 'str': 0, '773': 0, '0': 0,
[sym2]: 0, '-1': 0, '8': 0, 'second str': 0};
Reflect.ownKeys(obj);
// [ "0", "8", "773", "str", "-1", "second str", Symbol(comet), Symbol(meteor) ]
// Indexes in numeric order,
// strings in insertion order,
// symbols in insertion order
명세
Specification | Status | Comment |
---|---|---|
ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'Reflect.ownKeys' in that specification. |
Standard | Initial definition. |
ECMAScript (ECMA-262) The definition of 'Reflect.ownKeys' in that specification. |
Living Standard |
브라우저 호환성
BCD tables only load in the browser
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.