Chain binds in JavaScript
Question from the interview about bind
Oct 5, 2022
Output:
['a', 'b', 'c']
1
Method bind
adds arguments, but makes 1 bind to context. That is, this code is similar to the code:
The bind method locks the context at the moment it is called via a closure. Therefore, it is fixed rigidly and cannot be re-binded. This is roughly what a bind function might look like if you had to implement it yourself:
How to hide the source code of a function using the bind method
An interesting feature of using the bind method: the source code of the function will be hidden. Perhaps this option can be used in obfuscators to make reverse-engineering of the code more difficult.