Skip to content

Instantly share code, notes, and snippets.

@abhinavdhasmana
Created March 28, 2017 07:12
Show Gist options
  • Save abhinavdhasmana/0b18d32035e58d055caee576f5c8e79d to your computer and use it in GitHub Desktop.
Save abhinavdhasmana/0b18d32035e58d055caee576f5c8e79d to your computer and use it in GitHub Desktop.
'use strict';
function whoAmI() {
console.log('I am in local scope:', this);
this.insideFunction = function () {
console.log('I am an inside function:', this);
}
this.insideFunction();
}
this.myName = 'Abhinav';
whoAmI.apply(this);
// Output
// I am in local scope: { myName: 'Abhinav' }
// I am an inside function: { myName: 'Abhinav', insideFunction: [Function] }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment