Skip to content

Instantly share code, notes, and snippets.

@jyotiarora2610
Created July 1, 2019 17:22
Show Gist options
  • Save jyotiarora2610/b140bae07ebec7cb1f9535d23bcf3189 to your computer and use it in GitHub Desktop.
Save jyotiarora2610/b140bae07ebec7cb1f9535d23bcf3189 to your computer and use it in GitHub Desktop.
let name = {
firstname: 'jyoti',
lastname: 'arora'
}
var printFullName = function (city, state) {
console.log(`${this.firstname} ${this.lastname} from ${city}, ${state}`);
}
var printMyName = printFullName.bind(name, 'MZN');
printMyName('UP');
Function.prototype.myBind = function(...args) {
let obj = this;
let params = args.slice(1);
return function(...args2) {
obj.apply(args[0], [...params, ...args2]);
}
}
var printMyName2 = printFullName.myBind(name, 'MZN');
printMyName2('UP');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment