JavaScript-Garden icon indicating copy to clipboard operation
JavaScript-Garden copied to clipboard

Topic Name : Hidden Use of eval

Open divyanshu-rawat opened this issue 9 years ago • 0 comments

setTimeout and setInterval can also take a string as their first parameter.


function foo() {
    // will get called
}

function bar() {
    function foo() {
        // never gets called
    }
    setTimeout('foo()', 1000);
}
bar();

In node v7.3.0 Here setTimeout('foo()', 1000); will throw TypeError: "callback" argument must be a function

divyanshu-rawat avatar Jan 06 '17 16:01 divyanshu-rawat