Skip to content

Instantly share code, notes, and snippets.

Created May 18, 2020 23:19
What would you like to do?
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