Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //init test object /create namespace
- var test = window.test = {
- display : {},
- utils : {}
- };
- test.display = new function display(){ // create a singleton of the display object
- var utils = test.utils; // create an alias
- this.show = function(){
- return utils.sayHello(); // but the alias doesn't work, utils is an empty object
- // test.utils.sayHello() works perfectly
- };
- };
- test.utils = new function utils() { // create a singleton of the utils object
- this.sayHello = function(){
- alert('hello');
- };
- };
- test.display.show();
Add Comment
Please, Sign In to add comment