window.setTimeout
のコールバック関数の動きを見る為に下記コードを書きました。
JavaScript
1'use strict'; 2function sample () { console.log(this); } 3sample(); // undefined 4setTimeout(sample, 1000); // window
setTimeout(sample, 1000);
も undefined
をコンソール出力すると想定していましたが、期待に反して window
オブジェクトを出力しました。
そこで「HTML Living Standard」「HTML 5.1」の仕様書を読む事を試みました。
If the first method argument is a Function
Invoke the Function. Use the third and subsequent method arguments (if any) as the arguments for invoking the Function. Use method context proxy as the callback this value.
上記部分であろうことは想定できるのですが、私の英語読解能力では意味が理解できませんでした。
どなたか日本語で解説頂けないでしょうか。
もしくは window.setTimeout
に関する仕様書の日本語訳があれば紹介して頂けないでしょうか。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/02/16 02:14