<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script>
function namespace(ns) {
if(!ns || typeof ns !== "string" || !ns.length) return null;
var steps = ns.split(".");
var root = window;
for ( var i = 0, len = steps.length; i < len; i++) {
root[steps[i]] = root[steps[i]] || {};
root = root[steps[i]];
}
return root;
}
namespace("www.com");
www.com.say = function() {
console.log("hello.js....");
}
www.com.say();
/*
//test code.....
alert(window["a1"]);
window["a1"] = {};
var foo = (window["a1"]);
foo["ff"] = {};
alert(foo["ff"]);
*/
</script>
</body>
</html>