JavaScript Data Types

1/21/2020 4:05:12 AM

In this part we will discuss the JavaScript data type. When we decliner the variable then we assign the value, this value is must and should some data type. JavaScript have six primitive data type like string, integer, Boolean, null, undefined etc. when we declare the variable to contain the value then we use the “var” keyword. Now given bellow the code and explain the code:

<!DOCTYPE html>
 <script type="text/javascript">
  //int data type
    var myInt=10;
   //string data type
    var myStr1="Farhan Sakib";
    var myStr2='Reza Karim';
   //bool data type
   var a=true;
   var b=false;
 //object data type
 var person = {
  firstName : "Reza",
  lastName  : "Karim",
  age     : 29,
  eyeColor  : "black"
console.log(person.firstName + " is " + person.age + " years old.");

In this code we will show the int data type bool data type string data type also object data type. Object contain at a time many properties. This property will be int, string or others data type. We can see person is an object and  this person contain the string and int data type at a time.