javascript - unusual transitionend script behavior -
hey guys have @ script below ::
function transitionend() { var el = document.createelement('bootstrap') var transendeventnames = { webkittransition : 'webkittransitionend', moztransition : 'transitionend', otransition : 'otransitionend otransitionend', transition : 'transitionend' } (var name in transendeventnames) { console.log(name); if (el.style[name] !== undefined) { return { end: transendeventnames[name] } } } return false // explicit ie8 ( ._.) } transitionend(); now when script run following printed console :
"webkittransition" "moztransition" now if remove if check inside for loop , run following script instead ::
function transitionend() { var el = document.createelement('bootstrap') var transendeventnames = { webkittransition : 'webkittransitionend', moztransition : 'transitionend', otransition : 'otransitionend otransitionend', transition : 'transitionend' } (var name in transendeventnames) { console.log(name); } return false // explicit ie8 ( ._.) } transitionend(); what prints out following ::
"webkittransition" "moztransition" "otransition" "transition" why , expecting above result printed in both scripts , why getting differennt results ?? , console.log(name); before if condition , why if condition affecting result ?
thank you.
alex-z .
it’s not if-statement, it’s return-statement cancels loop (and function).
function myfunction() { console.log('hello'); return; // unreachable code; never run console.log('world'); } return statements in loops exact same thing.
function myfunction() { for(var = 0; < 1024; i++) { return i; } // unreachable code console.log('hello world'); }
Comments
Post a Comment