Object.getOwnPropertySymbols Function (JavaScript)

Returns the own symbol properties of an object. The own symbol properties of an object are those that are defined directly on that object, and are not inherited from the object's prototype.

Syntax

Object.getOwnPropertySymbols(object);  

Parameters

object
Required. The object that contains the own symbols.

Return Value

An array that contains the own symbols of the object.

Remarks

You need to use Object.getOwnPropertySymbols to get the symbol properties of an object. Object.getOwnPropertyNames will not return the symbol properties.

Example

The following code example shows how to get the symbol properties of an object.

var obj = {};  
var key = Symbol('description');  

obj[key] = 'data';  

var symbols = Object.getOwnPropertySymbols(obj);  

console.log(s[0].toString());  

// Output:  
// undefined  
// Symbol(description)  

Requirements

Supported in Microsoft Edge (Edge browser). Also supported in Store apps (Microsoft Edge on Windows 10). See Version Information.
Not supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards, Internet Explorer 10 standards, Internet Explorer 11 standards. Not supported in Windows 8.1.