DEV Community


Discussion on: Everything You Should Know About Javascript Variables

codenutt profile image
Jared Author

So, I looked into this because I was curious. The types themselves are in fact primitives and immutable, however, as noted in MDN:

That's why Primitives are immutable - instead of working on them directly, we're working on a copy, without affecting the original.

When we say let string = "some string", the "some string" portion is a primitive, however, that variable is wrapped in a String class, which does have methods.


Thank you for pointing that out and making me dig deeper!