- Trending Categories
- Data Structure
- Operating System
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
var number1=12; var number2=12;
To compare, we can use if else, instead of the ternary operator −
if(number1==number2) console.log("true"); else console.log("false");
Following is the code −
var number1=12; var number2=12; var result=(number1==number2)?true:false; console.log(result); if(number1==number2) console.log("true"); else console.log("false");
To run the above program, you need to use the following command −
Here, my file name is demo217.js.
The output is as follows −
- Ternary Operator in C#
- Ternary Operator in Python?
- C/C++ Ternary Operator
- Java Ternary Operator Examples
- Ternary Operator in Java
- Conditional ternary operator ( ?: ) in C++
- Ternary Operator in Dart Programming
- How to overload python ternary operator?
- What is ternary operator in C#?
- How Ternary operator in PowerShell Works?
- What is a Ternary operator/conditional operator in C#?
- Does Python have a ternary conditional operator?
- Ternary operator ?: vs if…else in C/C++
- What is ternary operator (? X : Y) in C++?