Chapter 6. OOP and Events

The more advanced JavaScript applications get, the greater is the need for structuring the code well. One way to do so is by using OOP, object-oriented programming. JavaScript itself is not an object-oriented language, but rather an object-based language. So there is a support for OOP, though it’s somewhat limited.

The second topic of this chapter is the general JavaScript event handling. Apart from the basics, special events (mouse and keyboard) are covered.

Creating a Class

Example . 

function UniversalClass() { }

There is no distinctive keyword for classes in JavaScript. Instead, each class is defined as a function. The difference between a regular function and this one is the way this function is later called: with ...

Get JavaScript™ Phrasebook: Essential Code and Commands now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.