Javascript hoisting example

<head>
&lt;title&gt;Hoisting example&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;h1>Hoisting in action&lt;/h1&gt;
    &lt;script type="application/javascript"&gt;
        var hoisting = "global variable";
        (function(){
            confirm("\"" + hoisting + "\"" + " click OK" );
            var hoisting = "local variable";
            alert(hoisting);
        })(); //self-executing function

     //Best practice - declare local variables at the beginning of the function
    &lt;/script&gt;
&lt;/body>
Subscribe to our newsletter for more code resources and news

Adrian Matei

Adrian Matei
Life force expressing itself as a coding capable human being

How to resize pictures from folder in Node.js with Jimp

Simple api tool implementation on localhost to resize from folder in Node.js with Jimp Continue reading