Javascript Essentials Notes
Javascript Essentials Notes
1. Variables
Classwork: Create variables for your name, age, and school. Homework: Create variables for your 3
favorite foods and log them.
2. Data Types
Classwork: Create a variable for each data type. Homework: Create an object with your name, age, and
favorite color.
3. Operators
• Arithmetic: + , - , * , / , %
• Assignment: = , += , -=
let total = 5 + 3;
total += 2;
1
4. Comparison Operators
• == : equal value
• === : equal value and type
• != , !== , > , < , >= , <=
let a = 5;
console.log(a == "5"); // true
console.log(a === "5"); // false
5. Logical Operators
• && : AND
• || : OR
• ! : NOT
6. Type Conversion
7. String Methods
2
Homework: Print the length of your name and convert it to uppercase.
9. Functions
function greet(name) {
console.log("Hello, " + name);
}
greet("Sam");
11. Loops
3
for (let i = 0; i < 5; i++) {
console.log(i);
}
12. Comments
// This is a comment
/* This
is multi-line */
try {
let result = 10 / 0;
console.log(result);
} catch (e) {
console.log("Error happened!");
}
4
let x = 10;
if (true) {
let x = 5;
console.log(x); // 5
}
console.log(x); // 10
Ready to Learn More? Next topics: DOM Manipulation, Events, ES6 Features, Objects & Prototypes.