Difference in behavior for copying contents in primitive and non primitive type
Dec 3, 2020
Data types basically specify what kind of data can be stored and manipulated within a program.There are six basic data types in JavaScript which can be divided into three main categories:
- Primitive datatype — String , Number, BigInt
- Trivial datatype — Null , Undefined
- composite datatype — Object such as array, function()
Here Primitive datatype is String, Number, BigInt which is immutable refers copy by value and non-primitive datatype is objects such as array, function() which is composite datatype which is mutable refers copy by reference.