Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This was the one thing I didn't understand. Why is using a global Symbol registry any better than just using string properties like usual?


There won't be a problem if the string happens to be e.g. "toString", I guess. Although they added a 'Map' for that, too.


    s1 = Symbol("cat");
    s2 = Symbol.for("cat");
    s3 = Symbol.for("cat");
    s1 == s2; // false
    s2 == s3; // true
You can still have Symbols outside the registry.


That I understand. What I don't understand is why s2 and s3 shouldn't just be vanilla strings.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: