Data Types Used in JavaScript

Data Types Used in JavaScript

There are six data types in javascript. Five are simple or primitive and one complex data type.







1. Undefined

The undefined type has only one value, which is the special value undefined.

When a variable is declared using var or let but not initialized, It is assigned the value of undefined.

 	var a; 	
 	let b; 	
 	console.log(a); // undefined 	
 	console.log(b); // undefined 

2. Null

The Null type is the second data type that has only one value: the special value null. Logically, a null value is an empty object pointer, which is why typeof returns “object” when it ’s passed a null value

 	var x = null; 	
 	console.log(typeof x); //object 

3. Boolean

The Boolean type is one of the most frequently used types in ECMAScript and has only two literal values: true and false

These values are distinct from numeric values, so true is not necessarily equal to 1, and false is not necessarily equal to 0.

 	var x = true;  	
 	var y = false; 

Note that the Boolean literals true and false are case-sensitive, so True and False (and other mixings of uppercase and lowercase) are valid as identifiers but not as Boolean values.

4. Number

There is a Number data type in javascript. which represent the integer and float both type of values.

 	var intNum = 55;         //integer  	
 	var floatNum1 = 1.1;  

5. String

The String data type represents a sequence of zero or more 16 - bit Unicode characters. Strings can be delineated by either double quotes ( “ ) or single quotes ( ‘ )

 	var firstName = “XYZ”;  	
 	var lastName = ‘abc’;  

6. Object

Objects in javascript start out as nonspecific groups of data and functionality. Objects are created by using the new operator followed by the name of the object type to create

 	var o = new Object();  

How To Use Server-Sent Events …

How To Use Server-Sent Events in Node.js to Build a Realtime App. Server-Sent Events (SSE) is a technology based on HTTP. On the client-side, it provides an API called EventSource (part of the HTML5 standard) that allows us to connect to the server a …

read more

How To Use node-cron to Run Sc …

How To Use node-cron to Run Scheduled Jobs in Node.js . cron provides a way to repeat a task at a specific time interval. There may be repetitive tasks such as logging and performing backups that need to occur on a daily or weekly basis.One method fo …

read more