Data Stored in var and How Its Content Changes in JavaScript



JavaScript variables are not typed but their values do have a type. The same variable can be assigned new values.

Example

Live Demo

<!DOCTYPE html>
<html>
   <body>
      <script>
         var a;
         document.write(typeof a+"\r
");          a = true;          document.write(typeof a+"\r
");          a = 5;          document.write(typeof a+"\r
");          a = "web";          document.write(typeof a+"\r
");       </script>    </body> </html>
Updated on: 2019-09-13T07:26:07+05:30

85 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements