Friday, 18 May 2012

setInterval vs setTimeout

var data ="testing or not to testing?";
function test(data) { console.log(data);}
var is_a_tune=self.setInterval("test(data)",1000);
// Stop
is_a_tune=window.clearInterval(is_a_tune)
var is_a_tune=self.setTimeout("test(data)",1000);
is_a_tune=window.clearTimeout(is_a_tune);
//Console:
var id ="testing or not to testing?";
undefined
function test(id) { console.log(id);}
undefined
var data ="testing or not to testing?";
undefined
function test(data) { console.log(data);}
undefined
var is_a_tune=self.setInterval("test(data)",1000);
undefined
6testing or not to testing?
is_a_tune=window.clearInterval(is_a_tune)
undefined
var is_a_tune=self.setTimeout("test(data)",1000);
undefined
testing or not to testing?
var is_a_tune=self.setTimeout("test(data)",100);
undefined
testing or not to testing?
var is_a_tune=self.setTimeout("test(data)",10000);
undefined
is_a_tune=window.clearTimeout(is_a_tune);
undefined
view raw gistfile1.js hosted with ❤ by GitHub
setInterval = Runs EVERY x secs setTimeout = Runs After x secs

No comments:

Post a Comment