Main Menu

Categories

Subscribe

Primitive & Reference Types in JavaScript

March 18th, 2009

Variables contain values and these values can be any number of datatypes such as a string or boolean etc. these datatypes can be organised into two groups: Primtive & Reference.

Primitive Types: Numbers, Boolean values and the Null and undefined types

A primitive type has a fixed size in memory. A number occupies eight bytes of memory and a boolean value occupies one bit for example. The number type is the largest of the primitive types.

Reference Types: Objects, arrays and functions.

A reference type can be of any size, so it cannot be stored in the eight bytes of memory asociated with each variable. Instead, the variable stores a reference to the value.

No Comments

Leave a Reply