var count = 1; function start(){ if(count == 0){ alert('0'); start(); } else{ count = 0; alert('1'); start(); } } start();