insanepenguin's Profile User Rating: -----

Reputation: 7 Worker
Group:
Active Members
Active Posts:
239 (0.15 per day)
Joined:
08-July 10
Profile Views:
2,798
Last Active:
User is offline Aug 30 2013 11:31 AM
Currently:
Offline

Previous Fields

Country:
GB
OS Preference:
Windows
Favorite Browser:
Chrome
Favorite Processor:
AMD
Favorite Gaming Platform:
PC
Your Car:
Who Cares
Dream Kudos:
0
Icon   insanepenguin learning learning learning

Posts I've Made

  1. In Topic: Javascript module pattern and name spacing

    Posted 29 Aug 2013

    Quote

    When you attach an object to the window object it becomes Global in a sense, it is part of the window object which is global.


    Yes that makes sense - the context is a single page/phone application, is using the window object a way to share and initialise various modules? e.g. The app module seems to initialise the others during start up

    function init() {
            if (window.index) index.init();
            if (window.settings) settings.init();
            if (window.about) about.init();
            if (window.router) router.init();
    
    }
    


    Thanks
  2. In Topic: Javascript module pattern and name spacing

    Posted 29 Aug 2013

    Thanks guys, makes a lot more sense now - what is the main advantage of attaching modules/objects to the window object? code structure and avoiding the global scope/name collisions?
  3. In Topic: Javascript module pattern and name spacing

    Posted 29 Aug 2013

    Thanks for the reply, really helped wrap my head around it!

    So essentially the
    (window.app = window.app || {}, $); 
    
    is looking if window.app currently exists in memory and if so passes this object into the anonymous function as an argument; if the object doesn't exist yet (like on a first execution or something) window.app is set to a new object?

    And the final parameter is passing jQuery into the function for some reason?

    Thanks again!

My Information

Member Title:
D.I.C Head
Age:
30 years old
Birthday:
March 11, 1984
Gender:
Location:
Wrexham, Wales
Years Programming:
0
Programming Languages:
C#

Contact Information

E-mail:
Private
Facebook:
http://www.facebook.com/insanealcoholicpenguin
Twitter:
mikejharper

Friends

insanepenguin hasn't added any friends yet.

Comments

insanepenguin has no profile comments yet. Why not say hello?