Last active
July 30, 2018 09:21
-
-
Save rrameshbtech/1e8418e3fd91a41280bef5405103d375 to your computer and use it in GitHub Desktop.
Explicit binding of this using call & apply
This file contains hidden or 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 siliconVallyOfIndia = { | |
city: 'Bengaluru', | |
speciality: 'software industries' | |
}; | |
const texCity = { | |
city: 'Tiruppur', | |
speciality: 'textile industries' | |
}; | |
const getSpeciality = function() { | |
return this.city + ' is known for ' + this.speciality; | |
}; | |
console.log(getSpeciality.call(siliconVallyOfIndia)); // Bengaluru is known for software industries | |
console.log(getSpeciality.apply(texCity)); // Tiruppur is known for textile industries |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment