Skip to content

IV Javascript

Sandesh Kota edited this page Dec 5, 2019 · 23 revisions
  • Output ?
const timerId = setTimeout (
    () => console.log('No wati time'),
    0
);
clearTimeout(timerId);
setTimeout(
  () => console.log('Hello after 0.5 seconds!'),
  500
);

for(let i = 0; i < 1e10; i++) {
  // Some logic
}
  • Call a function every 2 second. Retry it only for 5 times
let i =0;
const timerId = setInterval (
    () => {
        i++;
        if(i == 5){
            clearInterval(timerId);
        }
        var result = <some_ajax_call>();
        if(result == 'success'){
            clearInterval(timerId);
        }
    },
    2000
);

Clone this wiki locally