Outline
- JavaScript Fundamentals -- What is JavaScript?
- JavaScript Fundamentals -- Variables and Scope
- JavaScript Fundamentals -- Primitive Types
- JavaScript Fundamentals -- The this Keyword
-
JavaScript Fundamentals -- The JavaScript Console
- Introduction
- console.log + Exercise
- console.log Exercise Review
- console.info + Exercise
- console.info Exercise Review
- console.warn + Exercise
- console.warn Exercise Review
- console.error + Exercise
- console.error Exercise Review
- console.table + Exercise
- console.table Exercise Review
- console.assert + Exercise
- console.assert Exercise Review
- console.group + Exercise
- console.group Exercise Review
- Conclusion
-
JavaScript Fundamentals -- Logical and Comparison Operators
- Introduction to Logical and Comparison Operators
- Truthy and Falsy Values
- Comparison Operators -- Equality and Inequality
- Comparison Operators -- Equality and Inequality Exercise
- Comparison Operators -- Equality and Inequality Exercise Review
- Comparison Operators -- Relational
- Comparison Operators -- Relational Exercise
- Comparison Operators -- Relational Exercise Review
- Logical Operators -- Or
- Logical Operators -- Or Exercise
- Logical Operators -- Or Exercise Review
- Logical Operators -- And
- Logical Operators -- And Exercise
- Logical Operators -- And Exercise Review
- Logical Operators -- Not
- Logical Operators -- Not Exercise
- Logical Operators -- Not Exercise Review
- Logical Operators -- Nullish Coalescing
- Logical Operators -- Nullish Coalescing Exercise
- Logical Operators -- Nullish Coalescing Exercise Review
- Logical and Comparison Operators Conclusion
-
JavaScript Fundamentals -- Looping in JavaScript
- Introduction to Looping in JavaScript
- for Loops
- for Loops -- Why Use Them and Gotchas
- for ... of Loops
- Looping Exercise 1
- Looping Exercise 1 Review
- for ... in Loops
- Looping Exercise 2
- Looping Exercise 2 Review
- do while Loops
- Breaking out of Loops
- Skipping Passes Through Loops
- Looping Exercise 3
- Looping Exercise 3 Review
- Conclusion to Looping in JavaScript
-
JavaScript Fundamentals -- Functions in JavaScript
- Introduction to Functions in JavaScript
- Named Functions
- Anonymous Functions
- Arrow Functions
- Functions in JavaScript Exercise 1
- Functions in JavaScript Exercise 1 Review
- Default Parameters
- Named Parameters
- Rest Parameters
- Functions in JavaScript Exercise 2
- Functions in JavaScript Exercise 2 Review
- Functions in JavaScript Real Demo
- Conclusion to Functions in JavaScript
- JavaScript Fundamentals -- Strings, Numbers, & Dates
- JavaScript Fundamentals -- Objects in JavaScript
- JavaScript Fundamentals -- Arrays in JavaScript
- JavaScript Fundamentals -- Course Conclusion
Outline
- JavaScript Fundamentals -- What is JavaScript?
- JavaScript Fundamentals -- Variables and Scope
- JavaScript Fundamentals -- Primitive Types
- JavaScript Fundamentals -- The this Keyword
-
JavaScript Fundamentals -- The JavaScript Console
- Introduction
- console.log + Exercise
- console.log Exercise Review
- console.info + Exercise
- console.info Exercise Review
- console.warn + Exercise
- console.warn Exercise Review
- console.error + Exercise
- console.error Exercise Review
- console.table + Exercise
- console.table Exercise Review
- console.assert + Exercise
- console.assert Exercise Review
- console.group + Exercise
- console.group Exercise Review
- Conclusion
-
JavaScript Fundamentals -- Logical and Comparison Operators
- Introduction to Logical and Comparison Operators
- Truthy and Falsy Values
- Comparison Operators -- Equality and Inequality
- Comparison Operators -- Equality and Inequality Exercise
- Comparison Operators -- Equality and Inequality Exercise Review
- Comparison Operators -- Relational
- Comparison Operators -- Relational Exercise
- Comparison Operators -- Relational Exercise Review
- Logical Operators -- Or
- Logical Operators -- Or Exercise
- Logical Operators -- Or Exercise Review
- Logical Operators -- And
- Logical Operators -- And Exercise
- Logical Operators -- And Exercise Review
- Logical Operators -- Not
- Logical Operators -- Not Exercise
- Logical Operators -- Not Exercise Review
- Logical Operators -- Nullish Coalescing
- Logical Operators -- Nullish Coalescing Exercise
- Logical Operators -- Nullish Coalescing Exercise Review
- Logical and Comparison Operators Conclusion
-
JavaScript Fundamentals -- Looping in JavaScript
- Introduction to Looping in JavaScript
- for Loops
- for Loops -- Why Use Them and Gotchas
- for ... of Loops
- Looping Exercise 1
- Looping Exercise 1 Review
- for ... in Loops
- Looping Exercise 2
- Looping Exercise 2 Review
- do while Loops
- Breaking out of Loops
- Skipping Passes Through Loops
- Looping Exercise 3
- Looping Exercise 3 Review
- Conclusion to Looping in JavaScript
-
JavaScript Fundamentals -- Functions in JavaScript
- Introduction to Functions in JavaScript
- Named Functions
- Anonymous Functions
- Arrow Functions
- Functions in JavaScript Exercise 1
- Functions in JavaScript Exercise 1 Review
- Default Parameters
- Named Parameters
- Rest Parameters
- Functions in JavaScript Exercise 2
- Functions in JavaScript Exercise 2 Review
- Functions in JavaScript Real Demo
- Conclusion to Functions in JavaScript
- JavaScript Fundamentals -- Strings, Numbers, & Dates
- JavaScript Fundamentals -- Objects in JavaScript
- JavaScript Fundamentals -- Arrays in JavaScript
- JavaScript Fundamentals -- Course Conclusion
Logical and comparison operators are used frequently in JavaScript applications. You've may have seen them, but not known their names or the ways that they can be used. In this section we'll learn all about them.
Logical Operators
There are four logical operators that we'll cover: or (||
), and (&&
), not (!
), and nullish coalescing (??
).
When you use the or (||
) operator, you're telling the program to do something if this value is true, or if that value is true. As long as one of them evaluates to true, you'll be happy.
When you use the and (&&
) operator, you're telling the program to do something if this value is true and if that value is true. Both values need to evaluate to true.
When you use the not (!
) operator, you're looking for the opposite value of what you're comparing. So if you say "not true", you're looking for the value to be false.
The nullish coalescing operator is similar to the or operator, but instead of moving to the second statement if the first statement has any falsy value, it only moves on if the first statement is null
or undefined
.
With ||
and &&
, you can actually have more than two comparisons that you're looking at, but you need at least two. The list of comparisons can be as long as you want or need it to be. With ||
, you only need one of them to evaluate to true and with &&
you still need all of them to evaluate to true.
Comparison Operators
There are two sets of comparison operators, equality/inequality and relational.
Equality and inequality comparison operators check to see if one value is equal to another value, or if it is not equal to another value. Equality can be checked by using ==
or ===
, and inequality can be checked by using !=
or !==
. The ===
and !==
are doing a strict comparison, whereas ==
and !=
are doing an abstract comparison. We'll cover that in future videos.
Relational comparison comparison operators are checking to see if one value is greater than (>
), greater than or equal to (>=
), less than (<
), or less than or equal to (<=
) another value. These work just like they did in your math class. But don't worry, you don't have to have been good at math to understand this. 😃
For more background on logical and comparison operators, you can read the following blogposts: