JavaScript condition
Estimated reading time: 1 minutecondition
- if
- else
- else if
- tenary condition
if
if (condition_here){
//statement
}
else
if (condition_here){
//statement
}else{
// statement
}
else if
if (condition_here){
//statement
}else if (condition_here) {
// statement
}else if (condition_here) {
// statement
}else if (condition_here) {
// statement
}else {
// statement
}
tenary condition
condition ? trueValue : falseValue
switch
let product = 'and';
switch(product) {
case 'web':
console.log('web product');
break;
case 'android':
case 'and':
console.log('android development');
break;
default:
console.log('I am default');
}