Why JavaScript Data Types are Dynamic?

JavascriptWeb DevelopmentFront End Technology

JavaScript also has dynamic types. That would mean the same variable used for holding different data types in JavaScript.

Example

<html>
   <head>
      <script>
         var val;
         val = "Amit";
         document.write("String: "+val);

         val = 20;
         document.write("<br>Number: "+val);

         val = 40.90;
         document.write("<br>Number with decimals: "+val);
      </script>
   </head>
   <body>
   </body>
</html>
raja
Published on 16-Feb-2018 11:01:04
Advertisements