Created
August 17, 2024 21:02
-
-
Save Oluwasetemi/7e68cae7640fab8a441227320de60cdc to your computer and use it in GitHub Desktop.
First JS live class with AltSchool v4 student
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// variables and data types - number, string, boolean, null , undefined | |
// var, let, const | |
// declare a variable (identifier) | |
// var name; | |
let principal = 'Adedeji'; // string `, ", ' | |
// interpolation - ${} | |
let address = ` | |
1, Oluwaseyi Street, | |
Ojodu Berger, | |
` | |
let age = 20; // number | |
// | |
let isStudent = true; // boolean | |
let notAStudent = !isStudent | |
// assign a value to a variable | |
// name = "John"; | |
// null - nothing|empty or undefined (i do not have a value) | |
let country = null; | |
let letterO = 'O'; | |
let zero = 0; | |
console.log(typeof letterO) | |
// undefined - not defined | |
let state; | |
console.log(state) | |
// truthy and falsy values | |
// evertything is truthy except falsy values | |
// falsy values - false, 0, "", null, undefined, NaN | |
let isOfAge = 18; | |
const COST_PRICE = 3.142; | |
// COST_PRICE = 3.14; | |
// Assignment operators | |
// Please assign the value of 20 to isOfAge | |
isOfAge = 20; | |
// Arithmetic operators - +, -, * , /, %(reminder division - modulo), ++(increment), -- (decrement), ** (exponentiation) | |
5 % 2 // 1 | |
// % -modulo - differentiate between even and odd numbers | |
2 % 2 == 0 // even | |
3 % 2 == 1 // odd | |
console.log(5 - 2) | |
console.log(5 + 2) | |
console.log(5 * 2) | |
console.log(5 / 2) | |
// 5 raised to the power of 2 | |
console.log(5 ** 2) | |
console.log(5 ** 3) | |
// ++increment++ and --decrement-- - pre and post | |
let count = 0; | |
// pre-increment | |
console.log(++count) // 1 | |
console.log(++count) // 2 | |
console.log(++count) // 2 | |
console.log(count) | |
console.log(count++) // | |
console.log(count) | |
count // 4 | |
--count | |
--count | |
--count | |
count | |
count-- | |
count | |
// BigInt | |
let bigNumber = 10n; | |
// Summary - pre of (increment | decrement) - increment first before using the value | |
// post of (increment | decrement) - use the value first before incrementing or decrementing | |
// Comparison operators - ==, ===, !=, !==, >, <, >=, <= | |
// = assignment operator | |
// == // equality operator - checks the value only | |
// === // strict equality operator - checks the value and the data type | |
// != // not equal to | |
// !== // strict not equal to | |
console.log(2 > 3) | |
console.log(age >= 18) | |
console.log(2 < 3); | |
console.log(2 == '2'); | |
console.log(2 === '2') | |
// == - equality operator - checks the value | |
// semicolon | |
// ASI - Automatic Semicolon Insertion | |
// 1. when the line ends |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment