setT=function(exp, time){return setTimeout(function(){eval(exp)}, time)} str="console.log('foo')" setT(str, 100) id=setT("console.log('bar')", 100) clearTimeout(id) //out: foo only