I am just wondering, is there a way to assign a variable to the result of an if
statement. Would something like this be allowed in javascript?
var result = if (someVariable === 2) {
return something;
} else if (someOtherVariable) {
return somethingElse;
} else { return null; }
Where result
would end up being equal to whatever the if statement returns. Also, if this is not allowed in JS, is it allowed in other languages (just out of curiosity)?
Aucun commentaire:
Enregistrer un commentaire