In our last session, We had discussed about Comparison Operators, that they return a true or false value, i.e. boolean value. We might get a question after that, what is the use of boolean values (true or false). One of the use of these boolean values is in Conditional expression.
Now, we might get a question, What is Conditional expression. So, Conditional Expression or Conditional statements are the expressions that depend on boolean value for their execution. When condition is true, Conditional Expression gets executed, but when the condition is false, Conditional Expression doesn’t get executed.Article Sponsored Find something for everyone in our collection of colourful, bright and stylish socks. Buy individually or in bundles to add color to your sock drawer!
if(condition) {
block of code
}
if(true) {
console.log("Inside if block")
}
if(false) {
console.log("Inside if block")
}
let i=10
if(i>5) {
console.log("Inside if block")
}
if(i<5) {
console.log("Inside if block")
}
if(condition) {
block of code
} else {
block of code
}
if(true) {
console.log("Inside if block")
} else {
console.log("Inside else block")
}
if(false) {
console.log("Inside if block")
} else {
console.log("Inside else block")
}
let i=10
if(i>5) {
console.log("Inside if block")
} else {
console.log("Inside else block")
}
if(i<5) {
console.log("Inside if block")
} else {
console.log("Inside else block")
}
if(condition) {
block of code
} else if (condition) {
block of code
} else {
block of code
}
if(true) {
console.log("Inside if block")
} else if (true) {
console.log("Inside else if block")
} else {
console.log("Inside else block")
}
if(false) {
console.log("Inside if block")
} else if (true) {
console.log("Inside else if block")
}else {
console.log("Inside else block")
}
if(false) {
console.log("Inside if block")
} else if (false) {
console.log("Inside else if block")
}else {
console.log("Inside else block")
}
let i=10
if(i>5) {
console.log("Inside if block")
} else if (i===10) {
console.log("Inside else if block")
} else {
console.log("Inside else block")`
}
if(i<10) {
console.log("Inside if block")
} else if (i===10) {
console.log("Inside else if block")
} else {
console.log("Inside else block")`
}
We have covered below topics in this session today.
Objects, Classes and Constructor in Javascript Classes and Objects A class in any programming language…
We will start from object oriented programming basics like What are different concepts in Object…
Why we can not over ride a Constructor This is a very important question, that,…
What is Arrow Function In the last session, We had discussed about Anonymous Function. Anonymous…
What is Anonymous Function Anonymous Function is a type of function which has no name…
What is Map, Reduce and Filter Map Filter and Reduce are higher order methods for…