Javascript Data Types

Javascript Data Types

String Data Types

In Javascript we put strings inside single or double quotes.
A string can be text or anything that you can type on your keyboard.

// Using single quote
var name = 'Jane Doe';

// Using double quote
var myName = "Lia Sue";

Strings can also be empty

// Empty inside double quotes
var ourName = "";

// Empty inside single quotes 
var yourName = '';

Numbers Data Types

In Javascript we can store any number inside a variable.
For Javascript all numbers categorized into number data type.
For example:

// #1  Here we are storing the whole number 4 
var myNum1 = 4;
console.log(typeof myNum1);

// #2 Here we are storing the -50 (negative number -50) 
var myNum2 = -50;
console.log(typeof myNum2);

// Here we are storing a decimal number 7.6
var myNum3 = 7.6;
console.log(typeof myNum3);

Boolean Data Types

Boolean have 2 values.It’s true or false.
In computer language it is like 1 and 0

Comments are closed.