DEV Community

Nguyen Hoang
Nguyen Hoang

Posted on

Symbols - JavaScript const KEY1: unique symbol = Symbol('key1'); const KEY2: unique symbol = Symbol('key2'); const obj = { [KEY1]: 'Data for KEY1', [KEY2]: 'Data for KEY2', }; console.log(obj[KEY1]); // 'Data for KEY1'

Top comments (0)