Skip to content

Instantly share code, notes, and snippets.

@appcoreopc
Created March 25, 2016 05:50
Show Gist options
  • Save appcoreopc/8694a1c6827ca9ca175c to your computer and use it in GitHub Desktop.
Save appcoreopc/8694a1c6827ca9ca175c to your computer and use it in GitHub Desktop.
// 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