Why JS? π
I love that π
π©
1. Introduction
π©
2. Control flow
π©
3. Functions
π©
4. Arrays
π©
5. Objects
π©
6. DOM
// 1) Numbers
4
8.5
-3
// 2) Strings
"Hello, World!"
"815334455292"
// 3) Booleans
true
false
// 4) null
null
// 5) undefined
undefined// .1
200 % 3
// 2.
("Hello, " + "World!")[6]
// 3.
"hello".length % "world".lengthVariables are containers that store values
2 choices βπ»
1. Do you have values that you don't want changed or that will never change? Like the value of mathematical pi, they can be assigned to constΒ in javascript.
2. With let, we can re-assign the value.
They will discuss laterΒ
console.log
alert
promp
<!DOCTYPE html>
<html>
<head>...</head>
<body>
...
<script>
console.log('Give me pizza π');
<script>
</body>
</html>console.log('Give me pizza π');
index.html
pizza.js
<!DOCTYPE html>
<html>
<head>...</head>
<body>
...
<script src="./pizza.js"></script>
</body>
</html>| Operator | Name | Example | βResult |
|---|---|---|---|
| > | Greater than | x > 10 | false |
| >= | Greater than or equal to | x >= 5 | true |
| < | Less than | x < -50 | false |
| <= | Less than or equal to | x <= 100 | true |
| == | Equal to | x == "5" | true |
| != | Not equal to | x != "b" | true |
| === | Equal value and type | x === "5" | false |
| !== | Not equal value or equal type | x !== "5" | true |
x = 5
AND, OR, and NOT
| Operator | Name | Example | Result |
|---|---|---|---|
| && | AND | x < 10 && x !== 5 | false |
| || | OR | y > 9 || x === 5 | true |
| ! | NOT | !(x === y) | true |
const x = 10;
const y = "a"
y === "b" || x >= 10const x = 3;
const y = 8;
!(x == "3" || x === y) && !(y != 8 && x <= y)Values that aren't actually true or false, are still inherently "truthy" or "falsey" when evaluated in a boolean context
!"Hello World"
!""
!null
!0
!-1
!NaN