I know that there are 6 data types in JavaScript.
What are the \"reference\" types in JavaScript and what are the \"value\" data types in JavaScript?. Could someone list
From the standard#sec-8
The ECMAScript language types are Undefined, Null, Boolean, String, Number, and Object
The only "reference"
type is the Object
.
undefined, null, number, string, boolean and object
object is a reference type.
undefined
, null
, number
, string
, boolean
and object
of which only object
is a "reference" type.
There is no assignment by reference or pass by reference in javascript, whenever you pass/assign a "reference" type, you pass/assign a copy of the reference, you don't create a reference of the reference which would have different implications.
You can use these functions:
function isReferenceType( value ) {
return Object(value) === value;
}
function isPrimitiveType( value ) {
return Object(value) !== value;
}