retour au cours
Ce contenu n'est disponible que dans les langues suivantes :English, Español, Italiano, 日本語, 한국어, Русский, Türkçe, 简体中文. Merci de

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.