JavaScript Operators & JavaScript Conditionals | JavaScript Tutorial #4

TechWorld with Nana · Beginner ·🌐 Frontend Engineering ·6y ago

Key Takeaways

This video tutorial covers JavaScript operators and conditionals, including comparison operators, logical operators, and if-else statements, using simple examples and visualizations to help beginners learn.

Full Transcript

in this video you will learn with very simple examples and visualizations everything about conditionals and comparison operators in JavaScript so first let's see what comparison operators are let's consider as an example Facebook feature to display birthdays of its users so basically if today is your birthday Facebook will show a birthday icon and will send notifications to all your friends and for Facebook to check whether it's your birthday today basically it has to compare today with your birthdate right so that comparison or equals in JavaScript is expressed with 3 comparison sites like this so one comparison sign is reserved for assigning variables as we saw in one of my previous videos of variables so double or triple equal signs are used to check the Equality of two values so it's the difference between the two so let's say I have a variable age 30 so if I compare value of variable age to 30 then I get true right if I triple compare that I also get true so same results now if I compare the value with a string representation of 30 I also get true however if I triple check I get false and this is a difference between these two the double comparison checks equality of the values on tooth sides so checks the value here checks the value here and compares them by the value the triple equality compares value and also the type the data type of those values so if I have a number here and a number here which are same values then it's going to be true if I have a number value here which is defined here and a string value here of the same value I get false because the data types are not the same so that's the difference and obviously if I put here another value it's gonna be false in any case right like this or like this doesn't really matter and that little difference can actually have a big impact that's why these concept is important in JavaScript general rule is that you should in most cases use the triple equation to compare two values now let's consider another example where you order something on Amazon it says that shipping is free above purchase of 20 euros so when you add things to your cart program checks whether your order total is above 20 or below 20 and then calculates the shipment costs based on that and let's say charges you 5 euros if your if your total order is under 20 euros so now we don't have the equal check anymore but rather is it higher or is it lower so the way to check that is let's clear these so let's define variables so you have the total price let's say you gathered items that are 19 euros and now the program checks if total price is greater than 20 euros you get a boolean expression of false because this condition is wrong in the same way the program can also check the opposite direction so you can check whether your total price is below 20 but notice that we don't check for value 20 so what happens if the total price is exactly 20 so basically here we need to check that if total price is below 20 or 20 euros in both cases you get charged for the shipping so in order to do that you can combine those two expressions and say like this so either it should be less than 20 or to be exactly 20 for that to be true and as you see each of these comparisons return to you a boolean expression of either or true only one of these outcomes is possible so what this means is that in the program you check if this condition comes out as true then you want to offer free shipping otherwise you want to charge five euros for shipping and the way it's going to be written inside of the program using JavaScript syntax is if your price is greater than twenty here will be code that lets say calculates or sets the price of shipping so here we set it to zero there is no shipping cost otherwise is expressed with else shipping cost equals to five euros so this is how the conditions are used in JavaScript to check the condition and based on that divided this or if we switched that condition we can also check if total price is less than or equal to twenty then shipping cost will be set to five otherwise the shipping cost will be zero so to go back to some technical terms in JavaScript this here is called if-else statements whatever is inside if is called a condition so this thing here that evaluates to either true or false is a condition and this here that compares those two values is called a comparison operator so greater smaller equals etc all these are comparison operators but let's say you have a case where you have three different shipping costs right so for example if the price is below ten euros you get charged five euro shipping costs if it's below twenty you get charged only three euros and if it's above twenty you get charged nothing now you don't have if-else only but you have three conditions it's also super simple to do that with if-else so basically you check again if total price is less than or equal to ten you get charged five euros and here you are gonna say else/if which is another statement where you can write the conditional where we're gonna check where the total price is less than or equal to 20 in that case you get charged three euros and there comes our final else which is zero so now I have three conditions here so the first condition here says it's less than or equal to ten the first one checks another condition and the third one important thing to note here that the last else or the the else here doesn't have a condition explicitly but it implies that both of these above conditions were false so both of them were wrong B and because it's implicit we don't have to check it explicitly here so you could also go here and do that else if price is greater then 20 and this will work just fine however because it's implicit we don't need that so we sell comparisons between two values using equals higher or lower the final operator is not equals for example consider a feature where a web application checks whether user is a Premium Member or not obviously if you are not a premium user you won't see the cool features they have or you won't be able to access some premium content so when you log in program will check is user membership premium so with equals or it can check use a membership not premium and in order to express that negative comparison you use this syntax so not equals in JavaScript is expressed with exclamation mark and double equals and to show that in if-else statements let's say if user membership is not premium show user non-premium contents or maybe even recommend a premium upgrade as a marketing measure and else show premium contents and finally you can combine all these conditions so for example if today is your birthday and you have displayed that on your profile only then the program will show the notification so both conditions must be true so if today state is the same as your birth date and birthday displayed is true so here you can use a comparison with boolean true or false so both these conditions must be true for notification to be sent and in JavaScript the syntax for end is this so this basically is also a valid condition that you can also put inside of the if condition so if this whole thing is true then show notification else do not or another example back to the shipment cost let's say you don't pay for the shipment if the total price is over 20 euros or you have Amazon Prime account so the way to express that would be total price over 20 euros or amazon prime equals so here only one of them has to be true for you to get free shipment or in JavaScript is expressed with double pipes and again you can put that in if statement and say if either this or this is true then give a free shipment otherwise don't and you can also use negation in conditions for example you want to check whether this whole thing is false and the way to do that is using the exclamation mark and the brackets so basically this will check whether this whole condition is false now even if you understood all this concept it's always a good idea to practice them yourself so that you get it better so because of that I'm gonna put a link to practical exercises for conditionals and competitors in the video description below so make sure to check that out and practice yourself with a couple of examples and once you do that you can come back for another JavaScript video and if you don't want to miss that you can subscribe to my channel and click the notification bell so that you can notified when the next video is out so thanks for watching and see you in the next video

Original Description

Learn JavaScript Operators and JavaScript Conditionals | JavaScript if else statement ► Subscribe to me on Youtube: https://bit.ly/2z5rvTV In this video you will learn with simple examples and visualizations everything about conditionals, comparison operators and logical operators in JavaScript. I explain in detail: ❶ what comparison operators are, like equality and greater/less than and how to use them. ❷ Next I show how if else statements in javascript work and also explain why those javascript conditionals are useful. ➌ Last but not least you will learn logical operators, which combine conditionals. __________________________________________________________________________ 0:10 - Comparison Operators - equals, greater and less 4:20 - JavaScript Conditionals (if else statement) 7:55 - Comparison Operators - not equals 9:05 - Logical Operators ► For practicing 👩🏻‍💻: - https://www.w3schools.com/js/js_comparisons.asp - https://www.w3schools.com/js/js_if_else.asp ►► This is a complete JavaScript Tutorial for Beginners 💪🏼. If you are completely new to programming this will give you a step by step guide to learn JavaScript basic concepts and syntax. Subscribe or turn on the bell notification so you don't miss the new videos. 🙂 __________________________________________________________________________ 💡 Maybe also interesting for you: JavaScript Full Course here ► https://bit.ly/34yUrzj Top 3 programming languages | meta analysis ► https://youtu.be/9e6sUNhAB4M How websites work ► https://youtu.be/vcRmKtL4o_4 ► For any questions/issues/feedback 💡, please leave me a comment and I will get back to you as soon as possible. Also please let me know what you want to learn about JavaScript or web development in general. #javascript #js #webdevelopment #softwaredevelopment #coding #techworldwithnana #programming ----------------------------------------------------------------
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from TechWorld with Nana · TechWorld with Nana · 40 of 60

1 What is Docker? Docker container concept explained || Docker Tutorial 1
What is Docker? Docker container concept explained || Docker Tutorial 1
TechWorld with Nana
2 What is a Docker Container? Docker Demo || Docker Tutorial 2
What is a Docker Container? Docker Demo || Docker Tutorial 2
TechWorld with Nana
3 How to install docker? Step by Step || Docker Tutorial 3
How to install docker? Step by Step || Docker Tutorial 3
TechWorld with Nana
4 8 Basic Docker Commands || Docker Tutorial 4
8 Basic Docker Commands || Docker Tutorial 4
TechWorld with Nana
5 Debugging Docker Containers with docker exec and docker logs || Docker Tutorial 5
Debugging Docker Containers with docker exec and docker logs || Docker Tutorial 5
TechWorld with Nana
6 Docker vs Virtual Machine | simply explained || Docker Tutorial 6
Docker vs Virtual Machine | simply explained || Docker Tutorial 6
TechWorld with Nana
7 Overview of Workflow with Docker - Docker in Practice || Docker Tutorial 7
Overview of Workflow with Docker - Docker in Practice || Docker Tutorial 7
TechWorld with Nana
8 Developing with Docker - Docker in Practice || Docker Tutorial 8
Developing with Docker - Docker in Practice || Docker Tutorial 8
TechWorld with Nana
9 Docker Compose Tutorial - Docker in Practice || Docker Tutorial 9
Docker Compose Tutorial - Docker in Practice || Docker Tutorial 9
TechWorld with Nana
10 Dockerfile Tutorial - Docker in Practice || Docker Tutorial 10
Dockerfile Tutorial - Docker in Practice || Docker Tutorial 10
TechWorld with Nana
11 Private Repository explained | Registry on AWS - Docker in Practice || Docker Tutorial 11
Private Repository explained | Registry on AWS - Docker in Practice || Docker Tutorial 11
TechWorld with Nana
12 Docker Volumes explained in 6 minutes
Docker Volumes explained in 6 minutes
TechWorld with Nana
13 Deploying the containerized application with Docker Compose || Docker Tutorial 12
Deploying the containerized application with Docker Compose || Docker Tutorial 12
TechWorld with Nana
14 Docker Volumes Demo || Docker Tutorial 13
Docker Volumes Demo || Docker Tutorial 13
TechWorld with Nana
15 Docker vs Kubernetes vs Docker Swarm | Comparison in 5 mins
Docker vs Kubernetes vs Docker Swarm | Comparison in 5 mins
TechWorld with Nana
16 What is Kubernetes | Kubernetes explained in 15 mins
What is Kubernetes | Kubernetes explained in 15 mins
TechWorld with Nana
17 Kubernetes Components explained! Pods, Services, Secrets, ConfigMap | Kubernetes Tutorial 14
Kubernetes Components explained! Pods, Services, Secrets, ConfigMap | Kubernetes Tutorial 14
TechWorld with Nana
18 Kubernetes Architecture explained | Kubernetes Tutorial 15
Kubernetes Architecture explained | Kubernetes Tutorial 15
TechWorld with Nana
19 Benefits of Kubernetes | Scalability, High Availability, Disaster Recovery | Kubernetes Tutorial 16
Benefits of Kubernetes | Scalability, High Availability, Disaster Recovery | Kubernetes Tutorial 16
TechWorld with Nana
20 Minikube and Kubectl explained | Setup for Beginners | Kubernetes Tutorial 17
Minikube and Kubectl explained | Setup for Beginners | Kubernetes Tutorial 17
TechWorld with Nana
21 Top 3 programming languages to learn in 2020 | meta analysis
Top 3 programming languages to learn in 2020 | meta analysis
TechWorld with Nana
22 Kubectl Basic Commands - Create and Debug Pod in a Minikube cluster | Kubernetes Tutorial 18
Kubectl Basic Commands - Create and Debug Pod in a Minikube cluster | Kubernetes Tutorial 18
TechWorld with Nana
23 Kubernetes YAML File Explained - Deployment and Service | Kubernetes Tutorial 19
Kubernetes YAML File Explained - Deployment and Service | Kubernetes Tutorial 19
TechWorld with Nana
24 Run Jenkins in Docker Container - Jenkins Pipeline Tutorial for Beginners 1/4
Run Jenkins in Docker Container - Jenkins Pipeline Tutorial for Beginners 1/4
TechWorld with Nana
25 Create Multibranch Pipeline with Git - Jenkins Pipeline Tutorial for Beginners 2/4
Create Multibranch Pipeline with Git - Jenkins Pipeline Tutorial for Beginners 2/4
TechWorld with Nana
26 Jenkinsfile - Jenkins Pipeline Tutorial for Beginners 3/4
Jenkinsfile - Jenkins Pipeline Tutorial for Beginners 3/4
TechWorld with Nana
27 Trigger Jenkins Build automatically - Jenkins Pipeline Tutorial for Beginners 4/4
Trigger Jenkins Build automatically - Jenkins Pipeline Tutorial for Beginners 4/4
TechWorld with Nana
28 Complete Application Deployment using Kubernetes Components | Kubernetes Tutorial 20
Complete Application Deployment using Kubernetes Components | Kubernetes Tutorial 20
TechWorld with Nana
29 Kubernetes Namespaces Explained in 15 mins | Kubernetes Tutorial 21
Kubernetes Namespaces Explained in 15 mins | Kubernetes Tutorial 21
TechWorld with Nana
30 Configure Build Tools in Jenkins and Jenkinsfile | Jenkins Tutorial
Configure Build Tools in Jenkins and Jenkinsfile | Jenkins Tutorial
TechWorld with Nana
31 Complete Jenkins Pipeline Tutorial | Jenkinsfile explained
Complete Jenkins Pipeline Tutorial | Jenkinsfile explained
TechWorld with Nana
32 Kubernetes Ingress Tutorial for Beginners | simply explained  | Kubernetes Tutorial 22
Kubernetes Ingress Tutorial for Beginners | simply explained | Kubernetes Tutorial 22
TechWorld with Nana
33 What is Helm in Kubernetes? Helm and Helm Charts explained  | Kubernetes Tutorial 23
What is Helm in Kubernetes? Helm and Helm Charts explained | Kubernetes Tutorial 23
TechWorld with Nana
34 How Websites Work | simply explained with examples
How Websites Work | simply explained with examples
TechWorld with Nana
35 What is JavaScript? | JavaScript Tutorial #1
What is JavaScript? | JavaScript Tutorial #1
TechWorld with Nana
36 What is Ansible | Ansible Playbook explained | Ansible Tutorial for Beginners
What is Ansible | Ansible Playbook explained | Ansible Tutorial for Beginners
TechWorld with Nana
37 JavaScript Variables & JavaScript Data Types explained | JavaScript Tutorial #2
JavaScript Variables & JavaScript Data Types explained | JavaScript Tutorial #2
TechWorld with Nana
38 How Prometheus Monitoring works | Prometheus Architecture explained
How Prometheus Monitoring works | Prometheus Architecture explained
TechWorld with Nana
39 Where to write JavaScript | Where to execute JavaScript Code | JavaScript Tutorial #3
Where to write JavaScript | Where to execute JavaScript Code | JavaScript Tutorial #3
TechWorld with Nana
JavaScript Operators & JavaScript Conditionals | JavaScript Tutorial #4
JavaScript Operators & JavaScript Conditionals | JavaScript Tutorial #4
TechWorld with Nana
41 Pods and Containers - Kubernetes Networking | Container Communication inside the Pod
Pods and Containers - Kubernetes Networking | Container Communication inside the Pod
TechWorld with Nana
42 Kubernetes Volumes explained | Persistent Volume, Persistent Volume Claim & Storage Class
Kubernetes Volumes explained | Persistent Volume, Persistent Volume Claim & Storage Class
TechWorld with Nana
43 Kubernetes ConfigMap and Secret as Kubernetes Volumes | Demo
Kubernetes ConfigMap and Secret as Kubernetes Volumes | Demo
TechWorld with Nana
44 Pull Image from Private Docker Registry in Kubernetes cluster | Demo
Pull Image from Private Docker Registry in Kubernetes cluster | Demo
TechWorld with Nana
45 Kubernetes StatefulSet simply explained | Deployment vs StatefulSet
Kubernetes StatefulSet simply explained | Deployment vs StatefulSet
TechWorld with Nana
46 Yaml Tutorial | Learn YAML in 18 mins
Yaml Tutorial | Learn YAML in 18 mins
TechWorld with Nana
47 Terraform explained in 15 mins | Terraform Tutorial for Beginners
Terraform explained in 15 mins | Terraform Tutorial for Beginners
TechWorld with Nana
48 Setup Prometheus Monitoring on Kubernetes using Helm and Prometheus Operator | Part 1
Setup Prometheus Monitoring on Kubernetes using Helm and Prometheus Operator | Part 1
TechWorld with Nana
49 Managed Kubernetes Cluster explained | Kubernetes on Cloud (1/2)
Managed Kubernetes Cluster explained | Kubernetes on Cloud (1/2)
TechWorld with Nana
50 Step by Step Application Deployment on LKE using Helm | Kubernetes on Cloud (2/2)
Step by Step Application Deployment on LKE using Helm | Kubernetes on Cloud (2/2)
TechWorld with Nana
51 Kubernetes Operator simply explained in 10 mins
Kubernetes Operator simply explained in 10 mins
TechWorld with Nana
52 What is Infrastructure as Code? Difference of Infrastructure as Code Tools
What is Infrastructure as Code? Difference of Infrastructure as Code Tools
TechWorld with Nana
53 AWS EKS - Create Kubernetes cluster on Amazon EKS | the easy way
AWS EKS - Create Kubernetes cluster on Amazon EKS | the easy way
TechWorld with Nana
54 Prometheus Monitoring - Steps to monitor third-party apps using Prometheus Exporter | Part 2
Prometheus Monitoring - Steps to monitor third-party apps using Prometheus Exporter | Part 2
TechWorld with Nana
55 GitHub Actions Tutorial - Basic Concepts and CI/CD Pipeline with Docker
GitHub Actions Tutorial - Basic Concepts and CI/CD Pipeline with Docker
TechWorld with Nana
56 Docker Tutorial for Beginners [FULL COURSE in 3 Hours]
Docker Tutorial for Beginners [FULL COURSE in 3 Hours]
TechWorld with Nana
57 Kubernetes Services explained | ClusterIP vs NodePort vs LoadBalancer vs Headless Service
Kubernetes Services explained | ClusterIP vs NodePort vs LoadBalancer vs Headless Service
TechWorld with Nana
58 Kubernetes Tutorial for Beginners [FULL COURSE in 4 Hours]
Kubernetes Tutorial for Beginners [FULL COURSE in 4 Hours]
TechWorld with Nana
59 Containers on AWS Overview: ECS | EKS | Fargate | ECR
Containers on AWS Overview: ECS | EKS | Fargate | ECR
TechWorld with Nana
60 Kubernetes is dropping Docker support - What does it mean for YOU?
Kubernetes is dropping Docker support - What does it mean for YOU?
TechWorld with Nana

This video teaches JavaScript operators and conditionals, including comparison operators, logical operators, and if-else statements, with simple examples and visualizations. It helps beginners learn how to control program flow and make decisions based on certain conditions in JavaScript.

Key Takeaways
  1. Define variables to hold values for comparison
  2. Use comparison operators to check for equality, greater than, and less than conditions
  3. Combine conditions using logical operators to create more complex expressions
  4. Use if-else statements to control the flow of a program and make decisions based on certain conditions
  5. Check conditions with if-else statements
  6. Use else-if statements for multiple conditions
  7. Combine conditions using boolean true or false
  8. Use the double pipes operator to express 'or' conditions
💡 JavaScript conditionals and logical operators can be used to control program flow and make decisions based on certain conditions, and can be combined to create more complex expressions.

Related AI Lessons

Had my Frontend Developer interview with Capgemini (Application Developer) today, and I wanted to…
Prepare for a frontend developer interview with Capgemini by reviewing JavaScript fundamentals and practicing common interview questions
Medium · JavaScript
10 Frontend Developer Tools to Boost Productivity in 2026
Boost frontend productivity with 10 essential tools for modern web app development
Medium · Programming
10 Frontend Developer Tools to Boost Productivity in 2026
Boost frontend productivity with top 10 developer tools in 2026
Medium · JavaScript
The US Frontend Engineer Market in 2026: A Data-Driven Reality Check (and the Bias That Stops Us Seeing It)
US frontend engineer hiring demand peaked in 2022 and remains flat-depressed in 2026, contrary to common assumptions
Dev.to AI

Chapters (4)

0:10 Comparison Operators - equals, greater and less
4:20 JavaScript Conditionals (if else statement)
7:55 Comparison Operators - not equals
9:05 Logical Operators
Up next
The masks we wear | Zora Krstić | TEDxLuxembourgCity
TEDx Talks
Watch →