Object.getOwnPropertySymbols() JavaScript JS

The Javascript Object getOwnPropertySymbols() method retrieves an array of all its own symbol key properties. It will return an empty array if no symbol property is directly associated with an object.



Parameters: object: It represents the object whose symbol properties have to be fetched.

Return: An array of all own symbol key properties.


<!DOCTYPE html>
const obj = {};
x = Symbol('alpha');
y = Symbol.for('beta');
obj[x] = 'HELLO';
obj[y] = 'WORLD';
const objSymbols = Object.getOwnPropertySymbols(obj);
Please follow and like us:
Content Protection by DMCA.com