Working with objects and classes

If you want to start a lively discussion, ask a group of web developers: is JavaScript an object oriented language, or merely an object based one?, and retreat quickly! This discussion, while possibly arcane, has gone on year after year, and will probably continue for a while. A usual argument for the object-based opinion has to do with the fact that JS didn't include classes and inheritance and was prototype oriented. This argument has been voided now because the latest versions of JS provide two new keywords, class and extends, which behave in pretty much the same way as their counterparts in other official OO languages. However, keep in mind that the new classes are just syntactical sugar over the existing prototype-based inheritance; no new paradigm or model was truly introduced.

JS could do inheritance, but it was harder. To see how this was achieved in the old fashioned way, look at https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/Inheritance, and you'll have to agree that using class and extends is much better than assigning prototypes and constructors by hand!
..................Content has been hidden....................

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