
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Difference Between Primitive and Non-Primitive Data Types in JavaScript
The primitive data types are number, string, boolean, float etc. The non-primitive data types (Reference Type) are Array, Object etc.
Example
var number=10; var stringValue="John"; var booleanValue=true; var obj={}; var newArray=new Array(); console.log("The data type is="+typeof number); console.log("The data type is="+typeof stringValue); console.log("The data type is="+typeof booleanValue); console.log("The data type is="+typeof obj); console.log("The data type is="+typeof newArray);
To run the above program, you need to use the following command −
node fileName.js.
Output
Here, my file name is demo162.js. This will produce the following output −
PS C:\Users\Amit\JavaScript-code> node demo162.js The data type is=number The data type is=string The data type is=boolean The data type is=object The data type is=object
Advertisements