Symbols in JavaScript? [duplicate]
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
This question already has an answer here:
What is the motivation for bringing Symbols to ES6?
5 answers
I Googled a lot about new primitive type "Symbol" but still cannot understand actual use of it. What I understood is:
- They are a primitive type, just as integer or string.
- They are not a constructor function, hence you cannot use
new Symbol()
syntax.
But why is it used? String/Integer/Boolean have their uses which are clear, but what's the use of Symbol() exactly?
Moreover, for this code:
var data1 = Symbol();
var data2= Symbol('dummy');
why Symbol('dummy') === Symbol('dummy')
is false?
javascript ecmascript-6
marked as duplicate by adiga, Adriani6, Community♦ Jan 3 at 8:53
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
What is the motivation for bringing Symbols to ES6?
5 answers
I Googled a lot about new primitive type "Symbol" but still cannot understand actual use of it. What I understood is:
- They are a primitive type, just as integer or string.
- They are not a constructor function, hence you cannot use
new Symbol()
syntax.
But why is it used? String/Integer/Boolean have their uses which are clear, but what's the use of Symbol() exactly?
Moreover, for this code:
var data1 = Symbol();
var data2= Symbol('dummy');
why Symbol('dummy') === Symbol('dummy')
is false?
javascript ecmascript-6
marked as duplicate by adiga, Adriani6, Community♦ Jan 3 at 8:53
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
1
Everything is explained in the docs tho
– Islam Elshobokshy
Jan 3 at 8:51
the hand over value is only a description, not an identifier. this is the returned symbol itself.
– Nina Scholz
Jan 3 at 8:51
Possible duplicate of What is the motivation for bringing Symbols to ES6? and What are the possible usage scenarios for the new JavaScript “Symbol” datatype? and What is the “symbol” primitive data type in JavaScript
– adiga
Jan 3 at 8:54
add a comment |
This question already has an answer here:
What is the motivation for bringing Symbols to ES6?
5 answers
I Googled a lot about new primitive type "Symbol" but still cannot understand actual use of it. What I understood is:
- They are a primitive type, just as integer or string.
- They are not a constructor function, hence you cannot use
new Symbol()
syntax.
But why is it used? String/Integer/Boolean have their uses which are clear, but what's the use of Symbol() exactly?
Moreover, for this code:
var data1 = Symbol();
var data2= Symbol('dummy');
why Symbol('dummy') === Symbol('dummy')
is false?
javascript ecmascript-6
This question already has an answer here:
What is the motivation for bringing Symbols to ES6?
5 answers
I Googled a lot about new primitive type "Symbol" but still cannot understand actual use of it. What I understood is:
- They are a primitive type, just as integer or string.
- They are not a constructor function, hence you cannot use
new Symbol()
syntax.
But why is it used? String/Integer/Boolean have their uses which are clear, but what's the use of Symbol() exactly?
Moreover, for this code:
var data1 = Symbol();
var data2= Symbol('dummy');
why Symbol('dummy') === Symbol('dummy')
is false?
This question already has an answer here:
What is the motivation for bringing Symbols to ES6?
5 answers
javascript ecmascript-6
javascript ecmascript-6
asked Jan 3 at 8:49


VortexVortex
1
1
marked as duplicate by adiga, Adriani6, Community♦ Jan 3 at 8:53
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by adiga, Adriani6, Community♦ Jan 3 at 8:53
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
1
Everything is explained in the docs tho
– Islam Elshobokshy
Jan 3 at 8:51
the hand over value is only a description, not an identifier. this is the returned symbol itself.
– Nina Scholz
Jan 3 at 8:51
Possible duplicate of What is the motivation for bringing Symbols to ES6? and What are the possible usage scenarios for the new JavaScript “Symbol” datatype? and What is the “symbol” primitive data type in JavaScript
– adiga
Jan 3 at 8:54
add a comment |
1
Everything is explained in the docs tho
– Islam Elshobokshy
Jan 3 at 8:51
the hand over value is only a description, not an identifier. this is the returned symbol itself.
– Nina Scholz
Jan 3 at 8:51
Possible duplicate of What is the motivation for bringing Symbols to ES6? and What are the possible usage scenarios for the new JavaScript “Symbol” datatype? and What is the “symbol” primitive data type in JavaScript
– adiga
Jan 3 at 8:54
1
1
Everything is explained in the docs tho
– Islam Elshobokshy
Jan 3 at 8:51
Everything is explained in the docs tho
– Islam Elshobokshy
Jan 3 at 8:51
the hand over value is only a description, not an identifier. this is the returned symbol itself.
– Nina Scholz
Jan 3 at 8:51
the hand over value is only a description, not an identifier. this is the returned symbol itself.
– Nina Scholz
Jan 3 at 8:51
Possible duplicate of What is the motivation for bringing Symbols to ES6? and What are the possible usage scenarios for the new JavaScript “Symbol” datatype? and What is the “symbol” primitive data type in JavaScript
– adiga
Jan 3 at 8:54
Possible duplicate of What is the motivation for bringing Symbols to ES6? and What are the possible usage scenarios for the new JavaScript “Symbol” datatype? and What is the “symbol” primitive data type in JavaScript
– adiga
Jan 3 at 8:54
add a comment |
1 Answer
1
active
oldest
votes
This code Symbol('dummy') === Symbol('dummy')
is false
because each symbol is strictly unique.
Even if you use the same description (dummy), they are actually two different unique symbols.
They are used as identifiers.
You can read more about them here
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
This code Symbol('dummy') === Symbol('dummy')
is false
because each symbol is strictly unique.
Even if you use the same description (dummy), they are actually two different unique symbols.
They are used as identifiers.
You can read more about them here
add a comment |
This code Symbol('dummy') === Symbol('dummy')
is false
because each symbol is strictly unique.
Even if you use the same description (dummy), they are actually two different unique symbols.
They are used as identifiers.
You can read more about them here
add a comment |
This code Symbol('dummy') === Symbol('dummy')
is false
because each symbol is strictly unique.
Even if you use the same description (dummy), they are actually two different unique symbols.
They are used as identifiers.
You can read more about them here
This code Symbol('dummy') === Symbol('dummy')
is false
because each symbol is strictly unique.
Even if you use the same description (dummy), they are actually two different unique symbols.
They are used as identifiers.
You can read more about them here
answered Jan 3 at 8:52
quirimmoquirimmo
7,73811536
7,73811536
add a comment |
add a comment |
1
Everything is explained in the docs tho
– Islam Elshobokshy
Jan 3 at 8:51
the hand over value is only a description, not an identifier. this is the returned symbol itself.
– Nina Scholz
Jan 3 at 8:51
Possible duplicate of What is the motivation for bringing Symbols to ES6? and What are the possible usage scenarios for the new JavaScript “Symbol” datatype? and What is the “symbol” primitive data type in JavaScript
– adiga
Jan 3 at 8:54