Created
May 18, 2020 23:19
-
-
Save Omkaragrawal/35b2aea42e351f87923bb679aaa3436d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function f() { | |
return this.a; | |
} | |
var g = f.bind({a: 'azerty'}); | |
console.log(g()); // azerty | |
var h = g.bind({a: 'yoo'}); // bind only works once! | |
console.log(h()); // azerty | |
var i = f.bind({a: "bounded f for i"}); // but can bind original function again for a new output | |
console.log(i()); // bounded f for i | |
var o = {a: 37, f: f, g: g, h: h, i:i}; | |
console.log(o.a, o.f(), o.g(), o.h(), o.i()); // 37,37, azerty, azerty, bounded f for i |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment