Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Why JavaScript Data Types are Dynamic



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>
Updated on: 2020-01-16T10:18:32+05:30

172 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements