Syntax error Which data is stored in var and how its content is changed in JavaScript?

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: 2019-09-13T07:26:07+05:30

100 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements