Methods and Functions
In previous and subsequent chapters, you will see references to methods and discussions about methods that make them sound a good deal like functions. To help clarify the difference between methods and functions, this section skips ahead a bit to a discussion of objects in JavaScript. (The next chapter discusses objects in detail.)
Objects are collections of properties arranged in a hierarchy. The highest level of objects in the context of JavaScript and an HTML page is the window. Everything in an HTML page is a property of the window object. When a function is the property of an object, it is called a method. However, technically speaking, because everything in an HTML page is a property of the window object, all functions ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access