Primitive types in JavaScript

In every language there are variable type.In a programming language, if variables are container then data type is the type of container. type of container actually tells that what kind of stuff can be put in it. For example you don't want to put cookies in a bottle similarly you don't want to store an integer value in a variable of data type String

As its name indicates, a data type represents a type of the data which you can process using your computer program. So JavaScript also has 6 Primitive data types other than objects.

Lets Go though each of them.

  1. Undefined
    This represent the lack of existence.(Shouldn't set a variable to this).
  2. Null
    This also represent lack of existence.
  3. Boolean
    This represent a value that is true or false
  4. Number
    This is a floating point number. Normally programming languages have many types of number like int,long,double but JavaScript has only one
  5. String
    This represents a sequence of characters. single quotes ('') or double quotes ("") are used to specify strungs
  6. Symbol
    This type is used in ES6 which is the latest version of JavaScript

No comments:

Post a Comment