JS: Object.getOwnPropertySymbols

JS: Object.getOwnPropertySymbols

New in ES2015.

Object.getOwnPropertySymbols ( O )

Return a array of all own symbol key properties . (including non-enumerable ones).

const x = Symbol("x");
const obj = {};
obj[x] = 3;

console.log ( obj[x] ); // 3

// get a array of all symbol key properties
console.log (
 Object.getOwnPropertySymbols ( obj )
);
// [ Symbol(x) ]

[see JS: Symbol Tutorial]

// get a array of all symbol key properties
console.log ( Object.getOwnPropertySymbols ( Array.prototype ) );
// prints
// [ Symbol(Symbol.unscopables), Symbol(Symbol.iterator) ]

[see JS: List Properties]

Reference

ECMAScript 2015 §Fundamental Objects#sec-object.getownpropertysymbols

Liket it? Put $5 at patreon.

Or, Buy JavaScript in Depth