Practice: Immutable vs. Mutable in JavaScript

Primitive

In JavaScript, a primitive (primitive value, primitive data type) is data that is not an object and has no methods. There are 7 primitive data types: string, number, bigint, boolean, undefined, symbol, and null.

Most of the time, a primitive value is represented directly at the lowest level of the language implementation.

All primitives are immutable, i.e., they cannot be altered. It is important not to confuse a primitive itself with a variable assigned a primitive value. The variable may be reassigned a new value, but the existing value can not be changed in the ways that objects, arrays, and functions can be altered.


Source: Mozilla, https://developer.mozilla.org/en-US/docs/Glossary/Primitive
Creative Commons License This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.