bindを実行した後の関数プロパティ
重要度:5
関数のプロパティに値があります。bind
を実行すると変更されますか?その理由を教えてください。
function sayHi() {
alert( this.name );
}
sayHi.test = 5;
let bound = sayHi.bind({
name: "John"
});
alert( bound.test ); // what will be the output? why?
答え: 未定義
。
bind
の結果は別のオブジェクトです。test
プロパティはありません。