We want to make this open-source project available for people all around the world.

Help to translate the content of this tutorial to your language!

BuyEPUB/PDF
Share
back to the lesson

Function property after bind

importance: 5

There’s a value in the property of a function. Will it change after bind? Why, or why not?

function sayHi() {
 alert( this.name );
}
sayHi.test = 5;
let bound = sayHi.bind({
 name: "John"
});
alert( bound.test ); // what will be the output? why?

The answer: undefined.

The result of bind is another object. It does not have the test property.

AltStyle によって変換されたページ (->オリジナル) /