var exports = module.exports = {};
var base_url = "https://something.com:4242/";
exports.ordersummaryurl =base_url +"v1/api/stats?domain=order";
How do i do namespacing in the above code so that it has the below structure
urls.order.summary
var exports = module.exports = {};
var base_url = "https://something.com:4242/";
exports.ordersummaryurl =base_url +"v1/api/stats?domain=order";
How do i do namespacing in the above code so that it has the below structure
urls.order.summary
Javascript does not really have a "namespace" the same way other languages such as c# does.
How do I declare a namespace in JavaScript?
Taken from that link: the best way to get the functionality that you are describing is to encapsulate the data like such:
var urls = {
order: {
summary: "asdfasdfasdf"
},
foo: function() {
},
bar: function() {
}
};
To add on to this: keeping your functions in separate files and only including the "modules" that you need is another common way of achieving this.