Dave Partner

Javascript tutorial - 13 - Data Types

  • 0 Replies
  • 152 Views

0 Members and 1 Guest are viewing this topic.

*

Offline Dave Partner

  • Administrator
  • Full Member
  • *****
  • 109
    • View Profile
Javascript tutorial - 13 - Data Types
« on: November 08, 2016, 05:02:00 AM »





<!DOCTYPE html>
<html>
<head>
   
</head>


<body>
   <script type="text/javascript">
   //data types
       var utopiaWhatever ; //undefined
   
      var age = 16 + 3 + '12'; // Number
      var name = "Partner";    // String
      var fruits = ["Mango", "Cashew", "Apple"]; // Array
      var x = {gender:"alien", hobby:"running accross the atlantic"};    // Object
      var y = {
         'firstname':'dave',
         'middle name': 'Blair'
      }
      
      
      document.write(typeof y); //check variable type
      
      //check if a variable exists
      if(typeof utopiaWhatever == "undefined"){
         alert('age is undefined');
      }
      
      utopiaWhatever = 45;
   </script>
</body>
</html>