Skip to main content

  • The success story of Elon Musk is built on these two simple facts,

    1. He knows what he wants (yes, amazing clarity of thought)
    2. He has a strong desire to achieve what he wants (Desire drives him to work 100 hours / week)


    I would say these two underlying qualities are his success secrets. Infact, all successful men in history have these two qualities in common.

  • Cookies, including the session cookie, have an optional flag called secure. This basically means: “never send this cookie over a plain HTTP connection”. Enable this flag on your cookies, and they will not be sent with the HTTP request the browser does initially – but only once the connection switched to HTTPS, and can no longer be eavesdropped.

  • Whenever JavaScript executes a function, a 'scope' object is created to hold the local variables created within that function. It is initialised with any variables passed in as function parameters. This is similar to the global object that all global variables and functions live in, but with a couple of important differences: firstly, a brand new scope object is created every time a function starts executing, and secondly, unlike the global object (which in browsers is accessible as window) these scope objects cannot be directly accessed from your JavaScript code. There is no mechanism for iterating over the properties of the current scope object for example.

     

    So when makeAdder is called, a scope object is created with one property: a, which is the argument passed to the makeAdder function. makeAdder then returns a newly created function. Normally JavaScript's garbage collector would clean up the scope object created for makeAdder at this point, but the returned function maintains a reference back to that scope object. As a result, the scope object will not be garbage collected until there are no more references to the function object that makeAdder returned.

     

    Scope objects form a chain called the scope chain, similar to the prototype chain used by JavaScript's object system.

     

    A closure is the combination of a function and the scope object in which it was created.

1 - 20 of 1941 Next › Last »
20 items/page

Diigo is about better ways to research, share and collaborate on information. Learn more »

Join Diigo