1. web.graphic.print
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Lancaster, CA USA
    Rep Power

    Maybe this just isn't occurring to me

    Sorry if that's the case. I was wondering what this does:

    (function () {some_stuff = "hello world"})();
    Like why have the parentheses around the function with the parentheses after that?
    Fire Minded
    Brent Bevans
    43654 Colony dr., Lancaster, CA 93536
  2. #2
  3. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Rep Power
    This is a function call of an anonymous function.

    The parantheses at the end signify a function call like always. And the outer parantheses are required to make the parser recognize the function stuff as a function expression (as opposed to a function statement).

    So you have an anonymous function which is immediately called. This pattern is often used to avoid global variables. In your particular example, however, it's completely useless, because some_stuff is declared as global (for whatever reason).
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".

IMN logo majestic logo threadwatch logo seochat tools logo