Skip to content

Instantly share code, notes, and snippets.

@agjs
Created April 12, 2017 15:48
Show Gist options
  • Save agjs/35b41de8d6c17f08fb0f1b99b485d4c4 to your computer and use it in GitHub Desktop.
Save agjs/35b41de8d6c17f08fb0f1b99b485d4c4 to your computer and use it in GitHub Desktop.
function foo(role, level) {
console.log(`Your role is ${role} and your level is ${level}.`);
console.log(this);
}
foo();
var person = {
name: 'Julie'
};
foo.call(person, 'developer', 'pro');
foo.apply(person, ['developer', 'pro']);
const whoIs = foo.bind(person);
whoIs('developer', 'pro');
function multiply(a, b) {
return a * b;
}
const double = multiply.bind(null, 2);
console.log(double(3));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment