Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function(ns) {
- var r = typeof window != 'undefined' ? window : this;
- [].forEach.call(ns.split("×"), function(v) { r = r[v] = {} })
- })("mattn×hasegawayosuke×tokuhirom")
- mattn.hasegawayosuke.tokuhirom.Miyagawa = function() {
- alert('×××')
- }
- mattn.hasegawayosuke.tokuhirom.Miyagawa()
- // Another
- var namespace = function (ns_string) {
- var parts = ns_string.split('.'),
- parent = typeof window != 'undefined' ? window : this,
- i;
- // strip redundant leading global
- if (parts[0] === parent.toString()) {
- parts = parts.slice(1);
- }
- for (i = 0; i < parts.length; i += 1) {
- // create a property if it doesn't exist
- if (typeof parent[parts[i]] === "undefined") {
- parent[parts[i]] = {};
- }
- parent = parent[parts[i]];
- }
- return parent;
- };
- namespace("mattn.hasegawayosuke.tokuhirom");
- mattn.hasegawayosuke.tokuhirom.Miyagawa = function() {
- alert('ouffu')
- }
- mattn.hasegawayosuke.tokuhirom.Miyagawa()
Add Comment
Please, Sign In to add comment