Learn JavaScript
  • Introduction
  • Basics
    • Comments
    • Variables
    • Types
    • Equality
  • Numbers
    • Creation
    • Basic Operators
    • Advanced Operators
  • Strings
    • Creation
    • Concatenation
    • Length
  • Conditional Logic
    • If
    • Else
    • Comparators
    • Concatenate
  • Arrays
    • Indices
    • Length
  • Loops
    • For
    • While
    • Do...While
  • Functions
    • Declare
    • Higher order
  • Objects
    • Creation
    • Properties
    • Mutable
    • Reference
    • Prototype
    • Delete
    • Enumeration
    • Global footprint
Powered by GitBook
On this page
  1. Objects

Mutable

The difference between objects and primitive values is that we can change objects, whereas primitive values are immutable.

var myPrimitive = "first value";
myPrimitive = "another value";
// myPrimitive now points to another string.
var myObject = { key: "first value" };
myObject.key = "another value";
// myObject points to the same object.
PreviousPropertiesNextReference

Last updated 4 years ago