Skip to content

Instantly share code, notes, and snippets.

@dugdaniels
Created February 22, 2014 04:17
Show Gist options
  • Save dugdaniels/9148672 to your computer and use it in GitHub Desktop.
Save dugdaniels/9148672 to your computer and use it in GitHub Desktop.
function named(){
(function(){
this.foo = function() {
alert('bar');
}
})();
}
named.foo();
@iamdustan
Copy link

// calling `named()` with this will return an object which has the `foo` function as a member
function named(){
  this.foo = function() {
    alert('bar');
  }
  return this;
}

named().foo()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment