Me confundí un poco con JS bind , apply y this .
Preguntas
this y null son intercambiables en el siguiente fragmento?this en el siguiente contexto apunta a la window ? function curry(fn) { // your code here return function curryInner(...args) { if (args.length >= fn.length) return fn.apply(this, args); return curryInner.bind(this, ...args); //change this to null, still pass the test }; } const join = (a, b, c) => { return `${a}_${b}_${c}` } const curriedJoin = curry(join) console.log(curriedJoin(1, 2, 3)) // '1_2_3'No, this apunta al contexto this de la función en la que se encuentra.
En este caso, realmente no importa lo que ponga allí, ya que el único propósito de llamar bind es crear una copia de la función con los argumentos ya establecidos.
return curryInner.bind(null, ...args)esencialmente podría ser reemplazado por
return function() { return curryInner(args); }