filmov
tv
Conditional Operator in JavaScript - JavaScript Tutorial 24

Показать описание
Notes for You:: Conditional Operator in JavaScript - JavaScript Tutorial 24
Conditional Operator (?:):
- is the only ternary operator in JavaScript.
- It accepts 3 operands.
(operand1) ? operand2 : operand3;
Where:
operand1: should be a condition
operand2: value1
operand3: value2
Example Code:
var num=10;
var result = ( (num%2)==0) ? "even" : "odd";
Note:
- Conditional operator is a short hand notation for if else statement.
Example code:
var num=10;
var result;
if((num%2)==0){
result=”even”;
}
else{
result = “odd”;
}
=========================================
Follow the link for next video:
JavaScript Tutorial 25 - Assignment Operators in JavaScript | JavaScript Assignment Operators
Follow the link for previous video:
JavaScript Tutorial 23 - Logical Operators in JavaScript | JavaScript Logical Operators
=========================================
JavaScript Tutorials Playlist:-
=========================================
Watch My Other Useful Tutorials:-
jQuery Tutorials Playlist:-
jQuery UI Tutorials Playlist:-
Bootstrap Tutorials Playlist:-
=========================================
► Subscribe to our YouTube channel:
► Visit our Website:
=========================================
Hash Tags:-
#ChidresTechTutorials #JavaScript #JavaScriptTutorial
Conditional Operator (?:):
- is the only ternary operator in JavaScript.
- It accepts 3 operands.
(operand1) ? operand2 : operand3;
Where:
operand1: should be a condition
operand2: value1
operand3: value2
Example Code:
var num=10;
var result = ( (num%2)==0) ? "even" : "odd";
Note:
- Conditional operator is a short hand notation for if else statement.
Example code:
var num=10;
var result;
if((num%2)==0){
result=”even”;
}
else{
result = “odd”;
}
=========================================
Follow the link for next video:
JavaScript Tutorial 25 - Assignment Operators in JavaScript | JavaScript Assignment Operators
Follow the link for previous video:
JavaScript Tutorial 23 - Logical Operators in JavaScript | JavaScript Logical Operators
=========================================
JavaScript Tutorials Playlist:-
=========================================
Watch My Other Useful Tutorials:-
jQuery Tutorials Playlist:-
jQuery UI Tutorials Playlist:-
Bootstrap Tutorials Playlist:-
=========================================
► Subscribe to our YouTube channel:
► Visit our Website:
=========================================
Hash Tags:-
#ChidresTechTutorials #JavaScript #JavaScriptTutorial
Комментарии