const x = 'type'; x = 'a'; // Nothing happens, doesn't throw an error console.log(x); // LOGS: 'type'
It helps to think of strings in the way that we think of numbers, if we are to better understand how they work. Numeric values are also immutable primitives. If, for example, you could mutate numbers, you could change the meaning of the value
42 to be another number, say
13. In the same sense, you cannot mutate a string with a value of
gem to make it
Regular expressions are a very useful tool in a variety of situations. Save this cheatsheet for any time you need to look up their syntax and speed up your development.