Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2922500
symbols.js
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
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'
);
const
custom
=
{
[
Symbol
.
toStringTag
]
:
'MyCustomType'
};
test
(
'Symbol.toStringTag custom'
,
Object
.
prototype
.
toString
.
call
(
custom
),
'[object MyCustomType]'
);
summary
();
File Metadata
Details
Attached
Mime Type
application/javascript
Expires
Fri, Mar 27, 1:09 PM (2 d)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
512492
Default Alt Text
symbols.js (1 KB)
Attached To
Mode
rANT Ant
Attached
Detach File
Event Timeline
Log In to Comment