JS: Object.getOwnPropertySymbols

By Xah Lee. Date: . Last updated: .

New in JS2015.

Object.getOwnPropertySymbols(obj)

Return a Array of all own Symbol key properties . (including non-enumerable ones).

const xx = Symbol("xx");
const jj = {};
jj[xx] = 3;

console.log(jj[xx] === 3);

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

JavaScript, List Object Properties (to Array)