reading-notes

Reading Notes

View the Project on GitHub simon-panek/reading-notes

Code 201: 06 - JS Object Literals, The DOM


Read: JS Text pp 100-105

Objects group a set of variables and functions of a model


var hotel = {

    name: 'Quay',                             //property
    rooms: 40,                                //property
    booked: 25,                               //property
    gym: true,                                //property
    roomTypes: ['twin', 'double', 'suite'],   //property

    checkAvailability: function() {           //Method, this is a function
        return this.room - this.booked;
    }
};

Accessing an object Dot Notation


var hotelName = hotel.name;                         //declares the variable hotelName and assigns the value 'Quay' dot notation
var roomsFree = hotel.checkAvailability();          //declares teh variable roomsFree an assigns the value of the function output dot notation

var hotelName = hotel['name'];                      //same as above using square bracket notation
var roomsFree = hotel['checkAvailability']();       //same as above using square bracket notation

Read: JS Text pp 183-242

DOM Document Object Model

API Application Programming Interface

DOM Tree Access and Update

Caching DOM Queries

Methods that select single elements


Return to reading-notes Deployed Site

Return to reading-notes Mark Down