Voici un petit polyfill de la fonction bind.
Le "this" de la fonction fait référence à l'objet qui appelle la fonction bind non ? Alors pourquoi à la 5 eme ligne nous avons fn.apply(scope); ? fn et l'objet et non une fonction non ? Merci de m'éclairé sur ce point.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
 
Function.prototype.bind = function (scope) {
    var fn = this;
    return function () {
        return fn.apply(scope);
    };
}