Last active
August 20, 2019 21:45
-
-
Save W-Mills/7e33f1ebdc063e6611d8219e0e071fdd to your computer and use it in GitHub Desktop.
Clairifying this in Javascript example 4
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
const foo = { | |
bar: 10, | |
multiplyByBar: function(...args) { | |
args.forEach(function(arg) { | |
console.log(arg * this.bar); | |
}, this); | |
} | |
}; | |
const qux = foo.multiplyByBar.bind(foo); | |
foo.bar = 100; | |
qux(5); // logs 500 | |
qux(5, 10, 15); // logs 500, then 1000, then 1500 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment