rozdzia: Obiekty
==================
var empty_object = {};

var stooge = {
    "first-name": "Joe",
    "last-name": "Howard"
};
    
    
====================================
var flight = {
    airline: "Oceanic",
    number: 815,
    departure: {
        IATA: "SYD",
        time: "2008-09-22 14:55",
        city: "Sydney"
    },
    arrival: {
        IATA: "LAX",
        time: "2008-09-23 10:42",
        city: "Los Angeles"
    }
};
    
    
====================================
stooge["first-name"]     // "Joe"
flight.departure.IATA    // "SYD"
    
    
====================================
stooge["middle-name"]    // undefined
flight.status            // undefined
stooge["FIRST-NAME"]     // undefined
    
    
====================================
var middle = stooge["middle-name"] || "(none)";
var status = flight.status || "unknown";
    
    
====================================
flight.equipment                              // undefined
flight.equipment.model                        // wyjtek "TypeError"
flight.equipment && flight.equipment.model    // undefined
    
    
====================================
stooge['first-name'] = 'Jerome';
    
    
====================================
stooge['middle-name'] = 'Lester';
flight.equipment = {
    model: 'Boeing 777'
};
flight.status = 'overdue';
    
    
====================================
var x = stooge;
x.nickname = 'Curly';
var nick = stooge.nickname;
   // nick ma warto 'Curly', poniewa x oraz stooge
   //odnosz si do tego samego obiektu

var a = {}, b = {}, c = {};
   // a, b, c odnosz si 
   // do niezalenych pustych obiektw
a = b = c = {};
   // a, b, c odnosz si
   // do tego samego pustego obiektu

    
    
====================================
if (typeof Object.beget !== 'function') {
     Object.beget = function (o) {
         var F = function () {};
         F.prototype = o;
         return new F();
     };
}
var another_stooge = Object.beget(stooge);
    
    
====================================
another_stooge['first-name'] = 'Harry';
another_stooge['middle-name'] = 'Moses';
another_stooge.nickname = 'Moe';
    
    
====================================
stooge.profession = 'actor';
another_stooge.profession    // 'actor'
    
    
====================================
typeof flight.number      // 'number'
typeof flight.status      // 'string'
typeof flight.arrival     // 'object'
typeof flight.manifest    // 'undefined'
    
    
====================================
typeof flight.toString    // 'function'
typeof flight.constructor // 'function'
    
    
====================================
flight.hasOwnProperty('number')         // true
flight.hasOwnProperty('constructor')    // false
    
    
====================================
var name;
for (name in another_stooge) {
    if (typeof another_stooge[name] !== 'function') {
        document.writeln(name + ': ' + another_stooge[name]);
    }
}
    
    
====================================
var i;
var properties = [
    'first-name',
    'middle-name',
    'last-name',
    'profession'
];
for (i = 0; i < properties.length; i += 1) {
    document.writeln(properties[i] + ': ' +
            another_stooge[properties[i]]);
    }
}
    
    
====================================
another_stooge.nickname  // 'Moe'

// Usuwamy waciwo nickname z another_stooge, odsaniajc
// waciwo nickname prototypu.
delete another_stooge.nickname;

another_stooge.nickname  // 'Curly'
    
    
====================================
var MYAPP = {};
    
    
====================================
MYAPP.stooge = {
    "first-name": "Joe",
    "last-name": "Howard"
};

MYAPP.flight = {
    airline: "Oceanic",
    number: 815,
    departure: {
        IATA: "SYD",
        time: "2008-09-22 14:55",
        city: "Sydney"
    },
    arrival: {
        IATA: "LAX",
        time: "2008-09-23 10:42",
        city: "Los Angeles"
    }
};
    
    
==================