Created
March 25, 2016 05:50
-
-
Save appcoreopc/8694a1c6827ca9ca175c 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
// define our simple function with this.salary abd this tax. | |
function getSalary(name, deduction) { | |
var takeHomeAmount = this.salary - (this.tax + deduction); | |
console.log(name + " gets a monthly salary of :" + takeHomeAmount) | |
} | |
// next we are going create object with matching properties and bind to getSalary() method | |
// note that our object matches properties with function defined above. | |
var jessica = { salary : 3000, tax : 100 } | |
getSalary.bind(jessica, "jessica", 10)() // jessica gets a monthly salary of :2890 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment