Before beginning with the difference, let’s learn what are Primitive Datatypes. Primitive defines immutable values and introduced recently by ECMAScript standard.
- Numbers, eg. 3, 310.20 etc.
- Strings of text e.g. "This text string" etc.
- Boolean e.g. true or false.
After datatypes, let us discuss about Objects:
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!";
var str = new String("Demo string!");
It associates a key with accessor functions. This is to store a value.
- Related Articles
- What are primitive data types in Java?
- What are the differences between list, sequence and slice data types in Python?
- Java primitive data types
- What are the differences between Java classes and Java objects?
- C++ Program to convert primitive types to objects
- Golang program to convert primitive types to objects
- What are the differences between the 3 types of friction?