Created
July 1, 2019 17:22
-
-
Save jyotiarora2610/b140bae07ebec7cb1f9535d23bcf3189 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
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