0% found this document useful (0 votes)
12K views7 pages

CH02 03 Fundamentals Jonas JS Course

This document summarizes fundamental JavaScript concepts including: 1. Variables, data types, operators, and operator precedence. 2. Strings, template literals, type conversion, and type coercion. 3. Truthy and falsy values, switch statements, and the ternary operator. 4. Function declarations vs expressions, arrow functions, arrays, and objects. 5. The differences between dot and bracket notation when accessing object properties and methods.

Uploaded by

Jesse Quayle
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12K views7 pages

CH02 03 Fundamentals Jonas JS Course

This document summarizes fundamental JavaScript concepts including: 1. Variables, data types, operators, and operator precedence. 2. Strings, template literals, type conversion, and type coercion. 3. Truthy and falsy values, switch statements, and the ternary operator. 4. Function declarations vs expressions, arrow functions, arrays, and objects. 5. The differences between dot and bracket notation when accessing object properties and methods.

Uploaded by

Jesse Quayle
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

JQ-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;

Reassigned Re-Declared Hoisted Scoped

1. const N N N BLOCK
2. let Y N N BLOCK
3. Var Y Y Y FN/GLOBAL

12. DATA TYPES

A. PRIMITIVE: (IMMUTABLE) (Compared by VAL)


a variable that stored primitive value can be reassigned to a new value but the
existing value can’t be changed.

// This Works - bc can Reassign a VAR that had a Primitive VAL to a New VAL
let str = ‘hi’;
str = ‘bye’;

// This Doesn’t - bc Primitive VALs are Immutable.


let str = ‘hello’;
str[0] = ‘T’;
Boolean (T/F)
Number
String
BigInt (Very Large Integer)
Null (Intentional absence of a VAL)
Undefined (variable declared but not been assigned a VAL)
Symbol
B. NON-PRIMITIVE: (MUTABLE) (Compared by Reference)
OBJECTS, ARRAYS, FUNCTIONS

14/24/28. OPERATORS

Arithmetic: + - * / ** % ++ –

Assignment: = += -= *= /= %= **=

Comparison: == (VAL) === (VAL & Type) != !== < > <= >= ? (Ternary)

Logical: && || !

Conditional: IF…ELSE…ELSE IF (? : )

15. OPERATOR PRECEDENCE


MATH OPs (*, /, +, -) = Performed before Comparison OPs (>, <, etc)
Most Operations are Calculated = Left to Right
Change Precedence Order by using ()

17. STRINGS: “Sequence of Letters, Numbers, Symbols”

17. TEMPLATE LITERALS: (` `) (Back Ticks) = “string literals allowing


embedded expressions” (String Interpolation) (Interpolation = “the insertion of
something of a different nature into something else.”

20. TYPE CONVERSION: “Converting a STR to a NUM / NUM to a STR)

> c.log(Number(birthYear) + 18);


> c.log(String(23));

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

// Falsy “0” will be Converted to FALSE - so “money” IS NOT TRUE - so “else” =


Run
> const money = 0;
If (money) {
c.log(‘You are rich’);
} else {
c.log(‘Get a job’);
}

// Another Ex.
c.log(Boolean(‘Jesse’)); // TRUE

26. SWITCH STATEMENT

const expr = 'Papayas';


switch (expr) {
case 'Oranges':
console.log('Oranges are $0.59 a pound.');
break;
case 'Mangoes':
case 'Papayas':
console.log('Mangoes and papayas are $2.79 a pound.');
// expected output: "Mangoes and papayas are $2.79 a pound."
break;
default:
console.log(`Sorry, we are out of ${expr}.`);
}
27. STATEMENT v EXPRESSION

*Statement = an Instruction (a JS Program is a Sequence of S/Ments)


*Expression = Code that Evaluates to a VAL

Statement: => let x = 4;


Expression: => age > 16 ? “can drive” : “cant drive”;

28. TERNARY OPERATOR


> const isOfAge = age >= 18 ? ‘Beer’ : ‘Juice’;

32. STRICT MODE


‘use strict’; // At Top of JS File
*Not needed in MODULEs

34. FUNCTION DECLARATIONS vs EXPRESSIONS

FUNC. Declarations = Declare the FUNCs Name


> function calcAge (year) {

FUNC. Expressions = FUNCs has NO Name


> const myAge = function (year) {

35. ARROW FUNCTIONS

Implicit Return (dont have to use “RETURN” Keyword)


const even = arr.filter((v) => v % 2 === 0);

Single-line (Dont have to use () )


const getPumpedAbout = thing => `Pumped about ${thing}!`

// 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)

43. DOT vs BRACKET NOTATION


DOT: jesse.location = ‘Wellington’;
BRACKET: jesse[‘location’] = ‘Wellington’;

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.

for (let key in obj) {


console.log(obj[key]);
}

// 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',

calcAge: function (birthYeah) {


return 2037 - birthYeah;
}
}

You might also like