Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F7538096
symbols.js
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
963 B
Referenced Files
None
Subscribers
None
symbols.js
View Options
import
{
test
,
summary
}
from
'./helpers.js'
;
console
.
log
(
'Symbol Tests\n'
);
const
sym1
=
Symbol
(
'test'
);
test
(
'symbol typeof'
,
typeof
sym1
,
'symbol'
);
const
sym2
=
Symbol
(
'test'
);
test
(
'symbols are unique'
,
sym1
!==
sym2
,
true
);
test
(
'symbol description'
,
sym1
.
description
,
'test'
);
const
sym3
=
Symbol
();
test
(
'symbol without description'
,
sym3
.
description
,
undefined
);
const
obj
=
{};
const
symKey
=
Symbol
(
'key'
);
obj
[
symKey
]
=
'value'
;
test
(
'symbol as key'
,
obj
[
symKey
],
'value'
);
const
symFor1
=
Symbol
.
for
(
'shared'
);
const
symFor2
=
Symbol
.
for
(
'shared'
);
test
(
'Symbol.for same'
,
symFor1
===
symFor2
,
true
);
test
(
'Symbol.keyFor'
,
Symbol
.
keyFor
(
symFor1
),
'shared'
);
test
(
'Symbol.keyFor local'
,
Symbol
.
keyFor
(
sym1
),
undefined
);
test
(
'Symbol.iterator exists'
,
typeof
Symbol
.
iterator
,
'symbol'
);
test
(
'Symbol.toStringTag exists'
,
typeof
Symbol
.
toStringTag
,
'symbol'
);
test
(
'Symbol.hasInstance exists'
,
typeof
Symbol
.
hasInstance
,
'symbol'
);
summary
();
File Metadata
Details
Attached
Mime Type
application/javascript
Expires
Wed, Jun 17, 12:51 PM (1 d, 2 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
570830
Default Alt Text
symbols.js (963 B)
Attached To
Mode
rANT Ant
Attached
Detach File
Event Timeline
Log In to Comment