21

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 them by these 2 categories?

Esailija
140k24 gold badges280 silver badges328 bronze badges
asked Jul 17, 2012 at 11:08
2
  • 3
    Where did you hear of these categories existing? Commented Jul 17, 2012 at 11:10
  • 1
    from strongly typed languages.. like C#, Java.. Commented Jul 17, 2012 at 11:54

3 Answers 3

20

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;
}
answered Jul 17, 2012 at 11:11
Sign up to request clarification or add additional context in comments.

Comments

6

From the standard#sec-8

The ECMAScript language types are Undefined, Null, Boolean, String, Number, and Object

The only "reference" type is the Object.

answered Jul 17, 2012 at 11:19

Comments

3

undefined, null, number, string, boolean and object

object is a reference type.

RBT
26.3k24 gold badges178 silver badges267 bronze badges
answered Jul 17, 2012 at 11:16

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.