PROGRAMMING     CLIMBING

  minte9
reminder




Last update:   25-01-2022

Reference

A variable assigned to an object stores a reference to it.
 
/**
 * In Javascript a variable is alwayas copied as value.
 * 
 * Objects are different, they are stored by reference.
 * 
 * When we copy an object, the resulted two variables are ...
 * references to tht same object (that address in computer memory).
 */

let a = "Hello World";
let b = a;

console.log(a === b); // true

let c = {
    'name': 'John',
    'age': 30,
}
let d = c;
d.name = 'Sam';

console.log(c.name); // Sam (not John) - Look Here

Comparing

Two objects are equal only if they are the same object.
 
/**
 * Two independent objects are not equal ...
 * even thought they look alike.
 */

let a = {};
let b = {};

console.log(a == b); // different objects
    // false

let c = {};
let d = c;

console.log(c === d); // reference to the same object
    // true

Questions     github Objects
Methods
        A B C D E F
🔔
1/2