diff --git a/README.md b/README.md index a711022..a757323 100644 --- a/README.md +++ b/README.md @@ -72,9 +72,19 @@ is equivalent to `a->(createFn())`. There are **no other special rules**. ## Why a bind-`this` operator + +### `call` and `bind` are very common and should be easier [`Function.prototype.bind`][call] and [`Function.prototype.call`][bind] -are very common in **object-oriented JavaScript** code. -They are useful methods that allows us to apply functions to any object, +are very common in **object-oriented JavaScript** code; +they could even be considered core parts of its design. + +[TODO] + +[bind]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind +[call]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call + +### Tree-shakable methods should be easier +They allow developers to apply functions to any object, binding their first arguments to the `this` bindings within those functions, no matter the current object environment. `bind` and `call` allow us to **extend** an **object** with a function @@ -82,11 +92,10 @@ as if that function were **its own method**. They serve as an important link between the **object-oriented** and **functional** styles in JavaScript. -[bind]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind -[call]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call +[TODO] -Why then would we need an operator that does the same thing? -Because `bind` and `call` are vulnerable to **global mutation**. +### Protection against global mutation should be easier +`Function.prototype.bind` and `call` are vulnerable to **global mutation**. For example, when we run our code in an untrusted environment, an adversary may mutate global prototype objects