var hotel = { //Onject: hotel object
// **properties** //**key**
name: 'Quay', //string
rooms: 40, //number
booked 25,
gym:true, //Boolean
roomTypes:['twin'], ['double'],[''] // Array
// **method**
checkAvailability: function() {
return this.rooms - this.booked;
}
};
How browsers should create a model of HTML and how JS can access and update the contents in the browser window.
text
**array syntaxv preferred over item()
var hotItems=document.querySelectorA11('li.hot');
for (var i = 0; i < hotItems.length; i++) {
hotItems[i].className = 'cool';
}
var hotitems = document.querySelectorA11('li.hot'); //Store nodelist in array
if (hotItems.length > 0){ //if it contains items
for (var i=0; i<hotItems.length; i++) { //loop through each item
hotItems[i].className = 'cool'; //change value of class attribute
}
}
traversing the DOM Some browsers treat white space as a text element