Created
August 29, 2012 13:34
-
-
Save miguelludert/3512585 to your computer and use it in GitHub Desktop.
Snippet for cross platform javascript modules
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(){ | |
"use strict"; | |
var result = {}; // your javascript module | |
if(typeof define !== undefined && typeof define.amd !== undefined ){ | |
define(function(){ | |
return result; | |
}); | |
} else if(typeof module !== undefined && typeof module.exports !== undefined ){ | |
module.exports = result; | |
} else { | |
return result; | |
} | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
of course that doesn't work because typeof returns a string always and your comparisons are against undefined which is not a string.