Skip to content

Instantly share code, notes, and snippets.

@michaelBenin
Created June 28, 2012 19:17
Show Gist options
  • Save michaelBenin/3013308 to your computer and use it in GitHub Desktop.
Save michaelBenin/3013308 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<body>
<script type="text/javascript">
function NameSpace()
{
var e, t, n, r, i, s, o, u = arguments;
for (n = 0, r = u.length; n < r; n++)
{
t = u[n].split("."), e = window[t[0]] = window[t[0]] || {};
for (i = 1, s = t.length; i < s; i++) o = t[i], e = e[o] = e[o] || {}
}
return e
}
NameSpace('akn.user_info.username');
window.akn.user_info.username = "MichaelBenin";
var str = "Visit W3Schools email_removed";
str = str.replace(/email_removed/g, window.akn.user_info.username);
alert(str);
</script>
</body>
</html>
@michaelBenin
Copy link
Author

remove the namespace function and it'll break

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