-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Reference: Just Javascript course
Values and Code
Primitive Values
- They are a permanent part of our JavaScript universe. I can point to them, but I can’t create, destroy, or change them.
- Undefined (undefined), used for unintentionally missing values.
- Null (null), used for intentionally missing values.
- Booleans (true and false), used for logical operations.
- Numbers (-100, 3.14, and others), used for math calculations.
- BigInts (uncommon and new), used for math on big numbers.
- Strings ("hello", "abracadabra", and others), used for text.
- Symbols (uncommon), used to perform rituals and hide secrets.
Objects and Functions
- Objects and functions are also values but, unlike primitive values, I can manipulate them from my code.
- Objects ({} and others), used to group related data and code.
- Functions (x => x * 2 and others), used to refer to code.
Expressions
- We can ask questions with expressions.
- Expressions exist in our code, so they are not values. Rather, JavaScript will answer our expressions with values.
Values and Variables
Primitive Values Are Immutable
- They’re a permanent part of our JavaScript universe—we can’t create, destroy, or change them.
- For example, we can’t set a property on a string value because it is a primitive value.
let fifty = 50;
fifty.shades = 'gray'; // No!- Arrays are not primitive, so we can set their properties.
let arr = [212, 8, 506];
let str = 'hello';
arr[0] = 420;
console.log(arr); // [420, 8, 506]Variables are not values
- Each variable points to a particular value.
- We can change which value it points to by using the = assignment operator.
Variables Are Wires
- A “wire” is not a JavaScript concept—but it helps us imagine how variables point to values.
- When we do an assignment, there’s always a wire on the left, and an expression (resulting in a value) on the right.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels