- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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 datatypes 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
- Related Articles
- What are Primitive and Non-Primitive Data Types in JavaScript?
- What are the differences between JavaScript Primitive Data Types and Objects?
- What are primitive data types in JavaScript?
- How do JavaScript primitive/object types passed in functions?
- Bcc, Fcc, and Primitive Cubic Cell
- Widening Primitive Conversion in Java
- List out the default values of numeric and non-numeric primitive data types in Java?
- Java primitive data types
- Primitive Sources of Clothing
- How to get the primitive value of string in Javascript?
- Data Structures Stack Primitive Operations
- How primitive men used fire?
- How to convert JavaScript objects to primitive data types manually?
- Comparison of double and float primitive types in C#
- Primitive Wrapper Classes are Immutable in Java

Advertisements