Skip to content

Instantly share code, notes, and snippets.

@lkuper
Created November 5, 2014 22:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lkuper/92eaf7d7db11700977a1 to your computer and use it in GitHub Desktop.
Save lkuper/92eaf7d7db11700977a1 to your computer and use it in GitHub Desktop.
// Extension-side code
let AnObj = {
field: "hello",
thisIsATest: function() {
let str = this.field + " world!";
return str;
},
};
let thisIsATestBound = AnObj.thisIsATest.bind(AnObj);
Components.utils.exportFunction(AnObj.thisIsATest, window,
{defineAs: "thisIsATest"});
Components.utils.exportFunction(thisIsATestBound, window,
{defineAs: "thisIsATestBound"});
// User-side code
console.log(thisIsATest()); // "undefined world!"
console.log(thisIsATestBound()); // "hello world!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment