The Object getOwnPropertySymbols() Method
In JavaScript, the getOwnPropertySymbols()
method of the Object object allows you to obtain an array of symbols defined on an object.
Symbols are a feature introduced in ES2015, and this method was also added in ES2015.
Here is an example of how to use the getOwnPropertySymbols()
method:
1 | const dog = {} |
By calling Object.getOwnPropertySymbols(dog)
, you will receive an array containing the symbols associated with the dog
object, which in this case are Symbol(Roger)
and Symbol(Syd)
.
Tags: JavaScript, Object, getOwnPropertySymbols(), symbols