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:

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) ]

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