#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2013
    Posts
    1
    Rep Power
    0

    Why adding window object as function argument?


    I found code in a framework, which looks like this:

    (function (window) {
    //dosomething
    console.log(window);
    })(window);

    If I remove window object from arguments list - it's still the same window object inside this function.
    (function () {
    //dosomething
    console.log(window);
    })();

    So what's the point of adding it?
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    26
    Rep Power
    0
    Yes, it seems to be pointless
    in a "normal" page but in
    a page that uses a frame set
    it will ensure the use of the
    current frames window. It is
    is used in most JavaScript libs.

IMN logo majestic logo threadwatch logo seochat tools logo