-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy path3-for.js
More file actions
31 lines (24 loc) · 741 Bytes
/
3-for.js
File metadata and controls
31 lines (24 loc) · 741 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
'use strict';
const symbol1 = Symbol.for('name');
const symbol2 = Symbol.for('name');
if (symbol1 === symbol2) {
console.log(
'Symbols with identical description ' +
'from global registry list are equal',
);
}
console.log('symbol1:', symbol1);
console.log('Symbol("name"):', Symbol('name'));
console.log('Symbol.for("name"):', Symbol.for('name'));
console.log(Symbol('name') === Symbol.for('name'));
console.log(Symbol.for('name') === Symbol.for('name'));
const symbol3 = Symbol('name2');
console.log(
'key for symbol from global registry list:',
Symbol.keyFor(symbol1),
);
console.log(
'key for symbol which isnt in global registry list:',
Symbol.keyFor(symbol3),
);
console.log(symbol1[Symbol.toPrimitive]());