L.A. based web developer slowly parsing through Stack Overflow. If you like hot web dev tips or stories about being a freelancer, check out my newsletter: https://codenutt.substack.com/p/coming-soon
L.A. based web developer slowly parsing through Stack Overflow. If you like hot web dev tips or stories about being a freelancer, check out my newsletter: https://codenutt.substack.com/p/coming-soon
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.
In JavaScript, a primitive (primitive value, primitive data type) is data that is not an object and has no methods.
Actually numbers and strings do have methods 😉
That is a good point!
So, I looked into this because I was curious. The types themselves are in fact primitives and immutable, however, as noted in MDN:
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.Reference: developer.mozilla.org/en-US/docs/G...
Thank you for pointing that out and making me dig deeper!