Answer the question
In order to leave comments, you need to log in
Why is use strict not working in setTimeout?
Here is a link to the sandbox
Here is the code that is on the link.
<!DOCTYPE html>
<html>
<body>
<script>
'use strict';
function func() {
"use strict";
alert(this ); // выведет undefined (кроме IE9-)
}
setTimeout(func,0);
</script>
</body>
</html>
Answer the question
In order to leave comments, you need to log in
Because setTimeout calls the callback in the context of window .
Something like:
It is worth adding that when the script is executed by the worker, this in the setTimeout callback will refer to the WorkerGlobalScope .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question