mercredi 11 février 2015

is shorthand if statment refactoring possible? [duplicate]


This question already has an answer here:




Is there a way to make a shorthand for an if statement?


for



if(window.scrollY > 0 ){
alert("yes")
}


This shorthand will not work



window.scrollY > 0 ? alert("yes")


while this will work fine



window.scrollY > 0 ? alert("yes") : alert("no")


is there a way to write the shorthand without the : alert("no") part?


Aucun commentaire:

Enregistrer un commentaire