Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (7k points)

What is the difference between the primitive and non-primitive data types in Javascript?

2 Answers

0 votes
by (13.1k points)

Primitive data types mean the data type contains a single value, like 1, true.

Non-primitive data types mean the data type contains multiple values or complex data like an object.

The primitive data types are:

String, Number, Boolean

Non-primitive data types are:

Object, Array

The special data types are:

Null, Undefined

Want to be a full stack developer? Check out the full stack developer course from Intellipaat.

0 votes
by (1.7k points)

In JavaScript, these are the basic, immutable value types stored directly in memory. They include `string`, `number`, `boolean`, `null`, `undefined`, `symbol` and `bigint`. Here, when you're working on primitives, you're really dealing with the actual value itself, not with references.

Non-primitive data types or reference types include `object`, `array`, and `function`. They are more complex in that multiple values are stored in the form of a reference to a location in memory where the data is placed. Changing non-primitive data types changes the data since they are linked by references.

Related questions

0 votes
3 answers
0 votes
1 answer
+1 vote
2 answers

1.2k questions

2.7k answers

501 comments

693 users

Browse Categories

...