DEV Community

Cover image for Digging more into Variables in JavaScript
Arya Krishna
Arya Krishna

Posted on

Digging more into Variables in JavaScript

Now that we have a basic idea about the variable , we need to understand more about what goes inside those variable which are the different DataTypes.

Everything that we work inside of an application ultimately comes down to Primitive DataTypes.

  • Primitive data types include undefined, string, number and boolean

  • Undefined variables haven't been assigned values yet.If we put nothing inside a variable it is type of UnDefined.

var myUndefined;
Enter fullscreen mode Exit fullscreen mode
  • A string is a series of characters and is surrounded by quotes
var myStringWelcome = "Hello World"; 
Enter fullscreen mode Exit fullscreen mode
  • A number can be either an integer or a decimal
var myNumberInt = 100;
var myNumberDecimal = 100.100;
Enter fullscreen mode Exit fullscreen mode
  • Booleans have two values: true or false
var isMyBooleanTrue = true;
var isMyBooleanFalse = false;
Enter fullscreen mode Exit fullscreen mode

JavaScript is loosely typed, so the type is tied to the value held in the variable, not the variable itself!

Top comments (0)