Skip to content

Instantly share code, notes, and snippets.

@jasminegmp
Last active February 20, 2020 02:29
Show Gist options
  • Save jasminegmp/06963ada9654a20c80f5391c6c52297d to your computer and use it in GitHub Desktop.
Save jasminegmp/06963ada9654a20c80f5391c6c52297d to your computer and use it in GitHub Desktop.
let john = {
name: 'John'
}
let hobbies = ['painting', 'cooking', 'biking'];
let setName = function(hobby0, hobby1){
console.log(this.name + "'s hobbies are " + hobby0 + " and " + hobby1);
}
let myFunction = setName.bind(john, hobbies[0], hobbies[1]);
//as of here, nothing will be output because this myFunction is a function return
myFunction(); //this is when the output will be "John's hobbies are painting and cooking"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment