Data Types

 In JavaScript, there are seven primitive data types: 

1. boolean,

2. number, 

3. string, 

4. undefined,

5. object, 

6. function, and 

7. symbol

typeof is the primitive operator used to return the type of a variable.

var is20 = false; // boolean
typeof is20; // boolean

var age = 19;
typeof age; // number

var lastName = "Bae";
typeof lastName; // string

var fruits = ["Apple", "Banana", "Kiwi"];
typeof fruits; // object

var me = {firstName:"Sammie", lastName:"Bae"};
typeof me; // object

var nullVar = null;
typeof nullVar; // object

var function1 = function()
{
console.log(1);
}
typeof function1 // function

var blank;
typeof blank; // undefined

Comments

  1. This is helpful to understand about the primitive data types.

    ReplyDelete

Post a Comment