I'm fairly new to javascript and I saw this issue which I couldn't make any sense of,
Here's the code and inspector output from Chrome,
> test?'test':'ok'
"ok"
> [test?'test':'ok']
["ok"]
> ['ok' + test?'test':'ok']
["test"]
What is going on with this array? All I want is to create an array ['browser' + isIE? 'IE' : 'UNKNOWN'].
I could do it with [isIE? 'browser: IE' : 'browser: UNKNOWN'] which works. But I don't understand what is wrong with above syntax?
['browser' + isIE? 'IE' + 'UNKNOWN']doesn't look right. Should be['browser' + isIE ? 'IE' : 'UNKNOWN'](note the colon:)test?