0

Conditional ternary operator

This operator can only be used with numbers?

2nd Mar 2017, 6:05 PM
Vanessa Danielle Diniz da Silva
2 ответов
+ 3
You can use it for any assignement, even in an implicit assignement during a function call and or inside an expression: var x = 42; alert( x + ( (x>9) ? "this is a number" : "this is a digit" ) );
3rd Mar 2017, 10:45 AM
visph
visph - avatar
+ 2
Its not limited only for numbers. You can use this for other data types too.
2nd Mar 2017, 6:32 PM
Mirjalol Norqulov
Mirjalol Norqulov - avatar