
JavaScript Operators: The Basics You Need to Know
Operators are symbols that tells computer to take action: Arithmetic operators let a = 10; let b = 3; console.log(a + b); // 13 console.log(a - b); // 7 console.log(a * b); // 30 console.log(a / b); // 3.333... console.log(a % b); // 1 //gives remainder after division Comparison Operators == : Equal (loose) eg. 5 =="5" will return true ===: strict equal eg. 5=="5" will return false !=: not equal eg. 5!=3 will return true >: greater than 5>3 will return true < :less than 5<3 will return true Logical Operators && : AND || : OR ! : Not Truth Table( &&): True && True = True True && False = False False && True = False false && false = false Truth table(||): True || true = true true || false = true false || true = true false || false = false Truth Table : (!) true =false false = true example let age = 20; let hasID = true; console.log(age > 18 && hasID); // true console.log(age < 18 || hasID); // true console.log(!hasID); // false
Continue reading on Dev.to Tutorial
Opens in a new tab



