Home > Net >  What data types are value types in JavaScript?
What data types are value types in JavaScript?

Time:07-10

I know that objects and functions and arrays are reference types, but I am not sure what data types are value types.

Are the following data types value types?:

number

boolean

string

null

undefined

bigint

symbol

CodePudding user response:

According to the MDN documentation, there are following "primitive values".

Primitive values (immutable datum represented directly at the lowest level of the language):

  • Boolean type
  • Null type
  • Undefined type
  • Number type
  • BigInt type
  • String type
  • Symbol type

Primitive values are all types except objects define immutable values (that is, values which can't be changed). For example, Strings are immutable. We refer to values of these types as "primitive values".

But they also mention NaN and Symbol later on.

CodePudding user response:

Value types are for example strings, numbers, booleans, null and undefined. Reference types on the other hand include objects, arrays and functions.

  • Related