Skip to content

Instantly share code, notes, and snippets.

@roberjacobo
Last active August 20, 2021 21:36
Show Gist options
  • Save roberjacobo/e41517c78a20bd5cff3889f4200f7d72 to your computer and use it in GitHub Desktop.
Save roberjacobo/e41517c78a20bd5cff3889f4200f7d72 to your computer and use it in GitHub Desktop.
First of all what is Immutability?, in Object-Oriented and functional programming an immutable object (Unchangeable) is an object whose
state cannot be modified after it's created.
Now what is exactly a primitive value, they are any immutable value that directly represents the lowest level of that language, all
types except objects define immutable values.
There are seven primitive values in JS:
Boolean:
Represents a logical entity that can have two values, true or false. Boolean conditionals are often used to decide which sections
of code to execute (such as in if statements) or repeat (such as in for loops).
if (boolean conditional) {
// code to execute if the conditional is true
}
Null:
Represents the intentional absence of any object value, and is treated as falsy* for boolean operations.
*A falsy value is a value that is considered false when encountered in a boolean context.
Undefined:
The undefined type is the one that has an undefined value by default, when a variable is declared but not initialized.
Number:
Number type is a double precision that is usually occupying 64 bits in computer memory, it represents a wide dynamic
range of numeric values between -(2^53 − 1) and 2^53 − 1. The number type has three symbolic values +Infinity, -Infinity
and NaN
To check for the largest available value or smallest available value within ±Infinity, you can use the constants
Number.MAX_VALUE or Number.MIN_VALUE.
BigInt:
String:
Symbol:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment