Chapter 7
Working with Classes

Older versions of JavaScript supported classes but without using the class keyword. In the past, you may have found object-oriented (OO) programming in JavaScript rather primitive, especially if you were familiar with other mainstream languages. Even today, many programmers still think that JavaScript has little to do with OO programming. One of the main reasons for that is that the old syntax and semantics of working with classes were very confusing and error-prone. Modern JavaScript puts an end to that misery; now it is possible to create beautiful OO code with JavaScript.

In this chapter you’ll learn all about creating classes and defining both instance and static members. You’ll quickly find that the new syntax is more intuitive, easier to write, easier to maintain, and less error prone than the old syntax. In addition to learning about classes, you’ll explore the semantic differences from classes in other languages, how to examine properties, and how to make use of new built-in collection classes in JavaScript.

By the end of this chapter you will be able to not only freely use classes, but also mix the functional programming style from Chapter 5, Arrow Functions and Functional Style with the OO style we focus on here.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset