Created
March 19, 2020 18:16
-
-
Save OctavioBR/b9c4a6fce4ac7934da94792437e78e7e to your computer and use it in GitHub Desktop.
That vanilla js snippet which avoids polluting global scope exporting a single namespace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function (global, factory) { | |
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : | |
typeof define === 'function' && define.amd ? define(factory) : | |
(global.YourNameSpace = factory()); | |
}(this, function () { | |
'use strict'; | |
function method() {} | |
var YourNameSpace = { | |
method: method | |
}; | |
return YourNameSpace; | |
})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment