Chrome complains when I try to copy
inside setTimeout
.
setTimeout(function () { copy('a') }, 0)
Uncaught ReferenceError: copy is not defined
at <anonymous>:1:26
It doesn't work with the window
scope as well.
setTimeout(function () { window.copy('a') }, 0)
Uncaught TypeError: window.copy is not a function
Interestingly, if I keep the reference to copy
and reuse it, it works
cc = copy;
setTimeout(function () { cc('a') }, 0);
In Firefox, it doesn't throw any error, but it doesn't work even with the saved reference.
Why copy
function doesn't work inside setTimeout
, is it a bug?