Its being annoying
Following code :
var arrays = [1,2,3];
alert('Array has ' + (arrays.length > 0) ? 'multiple':'single' + ' value');
alerts as the multiple
where string is not concatenated with the ternary result.
But this code :
var arrays = [1,2,3];
alert('Array has ' + ((arrays.length > 0) ? 'multiple':'single') + ' value');
alerts as the Array has multiple value
where string is concatenated with the ternary result.
My question is :
- Why the first code is not concatenated with string.
- Is there any syntax error in first code, if so why it doesnt throw an error.