What are the JavaScript data types?

What are the JavaScript data types?

JavaScript is a dynamic language. In this a variable can hold different data types.
JavaScript has Primitive and non-primitive data types.

Primitive data types:    

  • String :  A string is a series of characters. We can use Single or double quotes for strings.

Eg:      var y = “Rahul”;

  • Number : In JavaScript, numbers can be written with or without decimals.    

Eg:     var y = 5;    

  • Boolean : Booleans can have only two values. They are true or false.  

Eg:     var x= 6;    

        var y = 7;    
        var z = 6;    
        x == z;     // This returns true    
        y == z;     // This returns false    

  • Null : Null represents emptiness. It has no value at all.    

Eg:     var y = null;

  •   Undefined : A varaible that is not defined any value if of the data type Undefined.    

Eg:     var y;

Non-primitive data types:

  •     Object: These are written with curly braces.    

Eg:     var info= {name:”Rahul”, age:30, gender:”Male”};          

  •     Array: These are groups which contain similar information.    

Eg:     var colours = ["Red", "Green", "Yellow"];          

  •     Date: There is built in date utility which can be used in JavaScript.

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.