Before beginning with the difference, let’s learn what are Primitive Datatypes. Primitive defines immutable values and introduced recently by ECMAScript standard.
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.