true ? 'ani': true ? var a=23:'gan'
Why I can't define var in trinary operator
You shouldn't make complicated the code. Ternary operation must be this format: (Condition) ? "if the condition is accepted" : "not accepted" I hope, it helps. Happy coding!
No, we can't declare variables inside ternary condition. https://stackoverflow.com/questions/19071803/declaring-a-variable-within-conditional-expressions-ternary-operator
true ?var a=23 : console.log(false) mesarthim why I can't use var a??
Aniket Ganguly If you want to define a variable, you don't have to write "var x" etc. Just write like x = 1. ////// true ? a=23 : a = 1 console.log(a) ///// I thought, you want to do sth like that. Actually, I didn't understand what you mean. Please, explain more.