Reference and Primitive Types in ES6

Reference and Primitive Types in ES6 tutorial we will learn about the reference datatypes array,object etc and primitive datatypes like int boolean etc

 

Reference and Primitive Types in ES6

Reference and Primitive Types in ES6

Primitive types

  • Primitive types are numbers, boolean values, and the null and undefined types are primitive
  • primitive type has fixed like number bytes ,boolean 1 bit
  • primitives are immutable (Immutables are the objects whose state cannot be changed once the object is created.)
  • Primitives are compared by value.

 

Reference type:

  • Objects, arrays, and functions are reference types.
  • Objects, for example, can be of any length.
  • Array can have any number of elements
  • These stores reference to the values
  • This reference is pointer to memory address
  • Non-primitives are mutable(type of variable that can be changed).
  • A mutable object is an object whose state can be modified after it is created.

If two objects or array have same properties and values they are not strictly equal

Reference type are compared by reference instead of value

 

Leave a Reply

Your email address will not be published. Required fields are marked *