0

What is Primitive Data Type in JavaScript ???

3rd Nov 2020, 3:53 PM
Noob Programmer
Noob Programmer - avatar
5 Réponses
+ 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.
4th Nov 2020, 3:43 AM
David Carroll
David Carroll - avatar
+ 1
Martin Taylor How , Primitive values are immutable???
4th Nov 2020, 2:41 AM
Noob Programmer
Noob Programmer - avatar