Javascript hoisting example


Dev-Bookmarks Logo

(P) Bookmarks.dev - Open source Bookmarks and Code Snippets Manager for Developers & Co. See our How To guides to help you get started. Public Bookmarks Repo on Github - Star


<head>
<title>Hoisting example</title>
</head>
<body>
    <h1>Hoisting in action</h1>
    <script type="application/javascript">
        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 
    </script>
</body>
Subscribe to our newsletter for more code resources and news

How to filter results list in Angular with input text

Real life example showing how to filter results list in Angular and its implementation with Angular pipes. Continue reading

GraphQL Resources to help you get started

Published on November 05, 2020