Skip to content

Instantly share code, notes, and snippets.

@aryak007
Created March 29, 2018 14:45
Show Gist options
  • Select an option

  • Save aryak007/03bcb897ce1789f63e0d6b8e1451f089 to your computer and use it in GitHub Desktop.

Select an option

Save aryak007/03bcb897ce1789f63e0d6b8e1451f089 to your computer and use it in GitHub Desktop.
function foo(){
console.log(this.bar);
}
var bar = "bar1";
var o2 = {
bar:"bar2",
foo:foo
};
var o3 = {
bar:"bar3",
foo:foo
};
foo(); //default binding - If in strict mode, default will make the call result undefined. If not, it will print bar1.
//https://stackoverflow.com/a/19850326/2309841
o2.foo();
o3.foo();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment