View on GitHub

reading-notes

Duckett JS Ch. 3 Object Literals (p.100-105)

What Is An Object?

var hotel = {
  name: 'Quay',
  rooms: 40,
  booked: 25,
  gym: true,
  roomTypes: ['twin', 'double', 'suite'],
  checkAvailability: function(){
    return this.rooms - this.booked;
  }
}

name = key , 'Quay' = value

Accessing an Object

var hotelName = hotel.name;
var roomFree = hotel.checkAvailabilty;

Duckett Ch. 5 Document Object Model (p.183-242)

Caching DOM Queries

var itemOne = getElementById ('one');

Selecting An Element From A Nodelist

-There are two ways to select an element from a nodelist : The item() method and array syntax. Both require the index number of the element you want.

var firstItem = elements.item(0);
var firstItem = elements[0];

Repeating Actions for an Entire NodeList

var hotItems = document.querySelectorAll('li.hot');
for ( var i = 0; i < hotItems.length; i++){
  hotelItems[i].className = 'cool';
}

Back to Homepage