In JavaScript, this is a context-sensitive binding: its value depends on how a function is called. A standalone function should not assume that this refers to a surrounding object. section 4.3.2
The main design choices are:
- Read properties through this when a method is deliberately invoked with its object context. section 4.3.2
- Use bind to correct the this reference when passing a function that depends on an object. section 4.3.2
- Prefer an explicit object parameter when possible; assemble(keys, obj) makes the dependency visible and avoids inferred state. section 4.3.2
Making context explicit
A context-dependent version reads keys with this[f]. Refactoring it to assemble(keys, obj) replaces hidden context with an explicit object argument, making the function easier to reason about and compose. section 4.3.2
const HasHash = keys => ({
calculateHash() {
return compose2(computeCipher, assemble.bind(this, keys))();
}
});
Compare bind(this, keys) with the later explicit-argument form to see how dynamic binding preserves behavior while leaving a context assumption. section 4.3.2



