
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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
What are the differences between JavaScript Primitive Data Types and Objects?
Before beginning with the difference, let’s learn what are Primitive Datatypes. Primitive defines immutable values and introduced recently by ECMAScript standard.
JavaScript allows you to work with three primitive data types,
- Numbers, eg. 3, 310.20 etc.
- Strings of text e.g. "This text string" etc.
- Boolean e.g. true or false.
JavaScript also defines two trivial data types, null and undefined, each of which defines only a single value. In addition to these primitive data types, JavaScript supports a composite data type known as the object.
After datatypes, let us discuss about Objects:
Objects
In JavaScript, objects are considered a collection of properties. Identify properties using key values. It has two types:
Data Property
It associates a key with a value.
Let’s say we take an example of a string with primitive data type and object:
For Primitive Datatype,
var str = "Demo string!";
For Object,
var str = new String("Demo string!");
Accessor Property
It associates a key with accessor functions. This is to store a value.
- Related Questions & Answers
- What are Primitive and Non-Primitive Data Types in JavaScript?
- What are primitive data types in JavaScript?
- What are primitive data types in Java?
- How to convert JavaScript objects to primitive data types manually?
- What are the differences between list, sequence and slice data types in Python?
- What are the differences between Java classes and Java objects?
- What are JavaScript data types and data structures?
- Java primitive data types
- What are the differences between JavaScript and PHP cookies?
- What are the differences between inline JavaScript and External file?
- What are the differences between mean.io and mean.js in javascript?
- What are the differences between clientHeight() and offsetHeight() in javascript?
- What are the data types, value types and reference types in C#?
- Difference between Primitive and non-primitive datatypes in JavaScript?
- What are Complex Data types in JavaScript?