CH02 03 Fundamentals Jonas JS Course
CH02 03 Fundamentals Jonas JS Course
1. VARIABLEs
2. DATA TYPES - Primitive, Non-Primitive
3. OP’S - Arithmetic, Assignment, Comparison, Logical, Conditional
4. OPERATOR PRECEDENCE
5. STRINGS
6. TEMPLATE LITERALS
7. TYPE CONVERSION
8. TYPE COERCION
9. TRUTHY/FALSY
10. SWITCH STATEMENT
11. STATEMENT v EXPRESSION
12. TERNARY OPERATOR
12. STRICT MODE
13. FUNCTION DECLARATIONS vs EXPRESSIONS
14. ARROW FUNCTIONS
15. ARRAYS
16. OBJECTS
17. DOT vs BRACKET NOTATION
18. OBJECT METHODS
10. VARIABLES
Declaring a Variable: let carName; (= “undefined”)
Assigning a Value: carName = toyota;
1. const N N N BLOCK
2. let Y N N BLOCK
3. Var Y Y Y FN/GLOBAL
// This Works - bc can Reassign a VAR that had a Primitive VAL to a New VAL
let str = ‘hi’;
str = ‘bye’;
14/24/28. OPERATORS
Arithmetic: + - * / ** % ++ –
Assignment: = += -= *= /= %= **=
Comparison: == (VAL) === (VAL & Type) != !== < > <= >= ? (Ternary)
Logical: && || !
Conditional: IF…ELSE…ELSE IF (? : )
20. TYPE COERCION: “Coercing a STR to a NUM / NUM to a STR (Using Basic
Operators)
*The “+” OP = only OP that Converts a Number to a String
*The Other 3 OPs - Convert a String to a Number
> c.log(‘I am ‘ + 23 + ‘years old’); // 23 = Converts to a String
> c.log(‘23‘ - ‘10’ - 3); // Outputs 10 (Strings = Converted to Number Type)
> c.log(‘20‘ / ‘10’); // Outputs 2 (Strings = Converted to Number Type)
21. TRUTHY/FALSY: “values that are considered T OR F when encountered in
a Boolean context.”
*ALL VALs are TRUTHY - Except: false, 0, -0, 0n, "", null, undefined, and NaN
// Another Ex.
c.log(Boolean(‘Jesse’)); // TRUE
// Multi-line
const implicit = thing => (
`Pumped about ${thing}!`
);
39. ARRAYS
An array is an ordered collection (0 Indexed) of data. Arrays are used to store
multiple values in a single variable.
42. OBJECTS
Objects Store KEY: VALUE Pairs (Non-Indexed)
Dot notation is faster to write and easier to read than bracket notation.
However, you can use variables with bracket notation, but not with dot
notation. This is especially useful for situations when you want to access a
property but don’t know the name of the property ahead of time. For example, if
we wanted to iterate over all the keys in an object, and access their values, we
could use bracket notation.
// Another ex
const variable = 'name';
const obj = {
👻
name: 'value',
variable: ' ',
};
✅
// Bracket Notation
obj[variable]; // 'value'
👻'
// Dot Notation
obj.variable; // '
44. OBJECT METHODS (FNs Inside OBJs)
const jonas = {
firstName: 'Jonas',
lastName: 'Schmedtmann',