Press "Enter" to skip to content

Hoaisting Example in JavaScript

Definition :

Declaration of variables after it is used then it is called as hoaisting.

Program :

<html>

   <head>

      <script language=”javascript”>

                   function display()

                   {

                   “use strict”;

                   //do add;

                  a=document.getElementById(“dd”);

                  b=document.createElement(“input”);

                  b.setAttribute(“type”,”text”);

                  b.setAttribute(“id”,”t1″);

                  a.appendChild(b);

                  var a,b;

                  }

                  </script> </head>

                  <body>

                     <div id=”dd”> </div> </br>

                                 <input type=”button” value=”Add” onClick=”display()”/> </br>

                  </body>

</html>

Be First to Comment

    Leave a Reply

    Your email address will not be published. Required fields are marked *