In JavaScript, this
refers to the calling context of the function. Unlike other more traditional languages, in JS it is only possible to know the value of this
within a function by examining, at runtime, what called the function. Let's look at some examples:
function blah() { console.log(this.cats); }
window.cats = 'dogs';
var o = { cats: 'pants' };