Get an array of symbols defined on an object.
Symbols are an ES2015 feature, and this method was introduced in ES2015 as well.
Example:
const dog = {}
const r = Symbol('Roger')
const s = Symbol('Syd')
dog[r] = {
name: 'Roger',
age: 6
}
dog[s] = {
name: 'Syd',
age: 5
}
Object.getOwnPropertySymbols(dog) //[ Symbol(Roger), Symbol(Syd) ]
Download my free JavaScript Beginner's Handbook and check out my JavaScript Course!
More js tutorials:
- How to get tomorrow's date using JavaScript
- How to get yesterday's date using JavaScript
- The String includes() method
- Work with objects and arrays using Rest and Spread
- How to flatten an array in JavaScript
- The String charAt() method
- The JavaScript super keyword
- The Object defineProperties() method
- An introduction to WebAssembly