Which data is stored in var and how its content is changed 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: 13-Sep-2019

53 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements