Last Updated: February 25, 2016
·
282
· brandturner

Relearning Javascript the Right Way

Week 2

function setName(obj) {
    obj.name = “Nicholas”;
    obj = new Object();
    obj.name = “Greg”;
}

var person = new Object();
setName(person);
alert(person.name); //”Nicholas”

In Javascript, all functions arguments are passed by value. Since a new object was instantiated within the function, the person object is no longer linked to obj.

null is an object type. Uninstantiated values are undefined. If you want to see what type of object it is, use this formula:

result = variable instanceof constructor
alert(person instanceof Object