@@ -72,21 +72,30 @@ is equivalent to `a->(createFn())`.
72
72
There are ** no other special rules** .
73
73
74
74
## Why a bind-` this ` operator
75
+
76
+ ### ` call ` and ` bind ` are very common and should be easier
75
77
[ ` Function.prototype.bind ` ] [ call ] and [ ` Function.prototype.call ` ] [ bind ]
76
- are very common in ** object-oriented JavaScript** code.
77
- They are useful methods that allows us to apply functions to any object,
78
+ are very common in ** object-oriented JavaScript** code;
79
+ they could even be considered core parts of its design.
80
+
81
+ [ TODO]
82
+
83
+ [ bind ] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind
84
+ [ call ] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call
85
+
86
+ ### Tree-shakable methods should be easier
87
+ They allow developers to apply functions to any object,
78
88
binding their first arguments to the ` this ` bindings within those functions,
79
89
no matter the current object environment.
80
90
` bind ` and ` call ` allow us to ** extend** an ** object** with a function
81
91
as if that function were ** its own method** .
82
92
They serve as an important link between
83
93
the ** object-oriented** and ** functional** styles in JavaScript.
84
94
85
- [ bind ] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind
86
- [ call ] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call
95
+ [ TODO]
87
96
88
- Why then would we need an operator that does the same thing?
89
- Because ` bind ` and ` call ` are vulnerable to ** global mutation** .
97
+ ### Protection against global mutation should be easier
98
+ ` Function.prototype. bind` and ` call ` are vulnerable to ** global mutation** .
90
99
91
100
For example, when we run our code in an untrusted environment,
92
101
an adversary may mutate global prototype objects
0 commit comments