Is it possible to declare the variable within a conditional expression?
for example: The code below return a syntax error (because I've declared the variable x within the conditional expression?).
var a = document.getElementById("userData");
var d = a.value;
function() {
(d.length>15)?(
alert("your input was too long")):(
var x = parseInt(d).toString(2),
a.value=x
);
}
obviously this can be fixed by simply adding var x;
outside the statement, but is it possible for variables to be declared here?
var a = (var b!=undefined) ? (var c=1) : (var d=2);
be legal