JavaScirpt Tutorial Index

JavaScript Tutorial Javascript Example Javascript comment Javascript Variable Javascript Data Types Javascript Operators Javascript If Else Javascript Switch Statement Javascript loop JavaScript Function Javascript Object JavaScript Arrays Javascript String Javascript Date Javascript Math Javascript Number Javascript Dialog Box Javascript Window Object Javascript Document Object Javascript Event Javascript Cookies Javascript getElementByID Javascript Forms Validation Javascript Email Validation Javascript Password Validation Javascript Re-Password Validation Javascript Page Redirect Javascript Print How to Print a Page Using JavaScript Textbox events in JavaScript How to find the largest number contained in a JavaScript Array?


JavaScript P5.js JavaScript Minify JavaScript redirect URL with parameters Javascript Redirect Button JavaScript Ternary Operator JavaScript radio button checked value JavaScript moment date difference Javascript input maxlength JavaScript focus on input Javascript Find Object In Array JavaScript dropdown onchange JavaScript Console log Multiple variables JavaScript Time Picker Demo JavaScript Image resize before upload Functional Programming in JavaScript JavaScript SetTimeout() JavaScript SetInterval() Callback and Callback Hell in JavaScript Array to String in JavaScript Synchronous and Asynchronous in JavaScript Compare two Arrays in JavaScript Encapsulation in JavaScript File Type Validation while Uploading Using JavaScript or jquery Convert ASCII Code to Character in JavaScript Count Character in string in JavaScript Get First Element of Array in JavaScript How to convert array to set in JavaScript How to get current date and time in JavaScript How to Remove Special Characters from a String in JavaScript Number Validation in JavaScript Remove Substring from String in JavaScript

Interview Questions

JavaScript Interview Questions

Javascript Data Types

It provides different data types to hold different types of values. There are two types of data types in Javascript.

  1. Primitive data types.
  2. Non-primitive data types.
As we know that JavaScript is a dynamic type language, which means we don't need to specify type of variable because it is dynamically used by JavaScript engine. Here we use var to specify the data type. It holds any type of values like numbers, strings, object etc.


var a=Ram; //String   
var b=20; //Number  
var x= {FirstName:''Ram'', lastName:''Doe''}; //Object

JavaScript primitive data types

There are 5 types of primitive data types in JavaScript.
Data Type Description
String It represents sequence of characters e.g. "Hello"
Number It represents numeric values e.g. 1,2,3,4,5,6.
Boolean It represents Boolean value either Right or Wrong.
Undefined It represents undefined values.
Null It means no values at all.

JavaScript non-primitive data types

There is 3 non-primitive data types are as follows:
Data type Description
Object It represents instance through which we can access members.
Array It represents group of similar values.
RegExp It represents regular expression.