Namespace by direct assignment

suggest change
//Before: antipattern 3 global variables
   var setActivePage = function () {};
   var getPage = function() {};
   var redirectPage = function() {};

//After:  just 1 global variable, no function collision and more meaningful function names
   var NavigationNs = NavigationNs || {};
   NavigationNs.active = function() {}
   NavigationNs.pagination = function() {}
   NavigationNs.redirection = function() {}

var at the top of a classic script creates a global, and the declaration is hoisted, so the first NavigationNs || {} sees undefined. A module does not create that global; export the object instead.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents