Тройные выражения в JavaScript
let memberType = 'basic';
let price = memberType === 'basic' ? 5 : 10;
In the example, the condition that is evaluated is whether memberType === 'basic'.
If this condition is true, then price will be 5, and otherwise it will be 10.
The equivalent long-hand conditional expression would be:
let memberType = 'basic';
let price;
if (memberType === 'basic') {
price = 5;
} else {
price = 10;
}
Gorgeous Goldfinch