I've been reading up and the different types of functions I can use in JavaScript. Many developers seem to agree that Object Literal Functions:
var hotel = {
  name: "Quay",
  rooms: 40,
  booked: 25,
  checkAvailability: function() {
    return this.rooms - this.booked;
  }
 };
and
function getArea(width, height) {
     return width * height;
}
are the best functions to use. Do some of the seasoned JavaScript developers on stack over flow feel the sam? I've read that I should not create global variables, and global functions.
My last question is, how do I know which function I should implement in my code? I'm kind of confusued, and could use some help. Thank you.