How to abbreviate ternary operator by JavaScript
This article mainly introduces how to abbreviate the ternary operator of JavaScript. It is very detailed and has certain reference value. Friends who are interested must finish reading it.
Ternary operator
The following is a good example of a complete if statement abbreviated to one line of code.
Const x = 20 answer;if (x > 10) {answer = 'greater than 10;} else {answer =' less than 10;}
Abbreviated as:
Const answer = x > 10? 'greater than 10': 'less than 10'; the above is all the content of the article "how to abbreviate the trinomial operator in JavaScript". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!