0

please tell me if these symbols are accessible or not Or I have to bind them to variable and then bind it to the object

let obj = {
    val1: 123,
    val2: 124,
    val3: 125,   
}
obj[Symbol("value")] = 31;
obj[Symbol("value")] = 621;

console.log(obj)
// val1: 123
// val2: 124
// val3: 125
// Symbol(value): 31
// Symbol(value): 21

Thanks yall;

Ivar
  • 5,377
  • 12
  • 50
  • 56
  • Use [`Object.getOwnPropertySymbols(obj)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertySymbols). However, in actual code where you *want* to access them, it would be much cleaner to bind them to variables. – Bergi Aug 22 '21 at 20:06

0 Answers0