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;
}







0
















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?










share|improve this 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




















0
















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?










share|improve this 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
















0












0








0









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?










share|improve this question















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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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
















  • 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














1 Answer
1






active

oldest

votes


















0














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






share|improve this answer






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    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






    share|improve this answer




























      0














      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






      share|improve this answer


























        0












        0








        0







        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






        share|improve this answer













        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







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 3 at 8:52









        quirimmoquirimmo

        7,73811536




        7,73811536

















            Popular posts from this blog

            MongoDB - Not Authorized To Execute Command

            How to fix TextFormField cause rebuild widget in Flutter

            in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith