0
What is Primitive Data Type in JavaScript ???
2 Answers
+ 2
Abir Sheikh Your follow up question is a bit unclear. If I understand it correctly, you want to know how are primitive values immutable, as in, they cannot be changed.
Assuming this is your question, think of it like this...
In the following line:
let one = 1
The variable object `one` is of type Number when assigned 1 and is mutable. You can assign a different value to this named object.
The value 1 is of type number, which is an immutable primitive value.
That is to say, the primitive number value 1 cannot be assigned a different value.
NOTE: The first letter casing matters when differentiating between number (primitive type) and Number (object wrapper).
This applies to other primitive values of different primitive types which may have a similar object wrapper type.
Examples: string, boolean, bigint, symbol, and number.
The only primitive type without an object wrapper is undefined.
Javascript automatically wraps primitive string and boolean values with their respective object wrappers.
+ 1
Martin Taylor How , Primitive values are immutable???