1const isBlack = false;const text = isBlack ? 'Yes, black!' : 'No, something else.';console.log(text);// "No, something else."
1//This is what is called a 'Conditional operator'
2let result = condition ? value1 : value2
3// ^^ ^^ ^^
4let result = 1 == 2 ? "YES" : "NO!"
5console.log(result) //output: "NO!"
6
7//Basically a short form of an if-else statment
1//XCal - Javascript Inline Conditional Sample (condition brackets only for clarity)
2// v-? = Conditional Operator
3// v v-: = True/False result value separator
4//Format = v-Condition-v ? v-When True-v : v-When False-v
5var vResult = (null == null) ? 'Condition True' : 'Condition False';
6//vResult is now 'Condition True';