JavaScript: Object.getOwnPropertySymbols

JavaScript: Object.getOwnPropertySymbols

New in ES2015.

Object.getOwnPropertySymbols ( O )

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

var x = Symbol("x");
var 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 JavaScript: Symbol Tutorial

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

〔►see JavaScript: Access Property, List Properties

Reference

ECMAScript 2015 §Fundamental Objects#sec-object.getownpropertysymbols

Like what you read? Buy JavaScript in Depth
or, buy a new keyboard, see Keyboard Reviews.