intermediate in javascript looking for a book to l

2019-06-14 05:08发布

问题:

I am an intermediate javaScript programmer, and i am interested in expanding my knowledge in object oriented programming (especially object oriented JavaScript).

I would prefer a book over browsing scattered web resources, does anyone have an idea of which book will be best to get a head start with?

Thanks

回答1:

Object-Oriented JavaScript published by Packt was an invaluable resource for me recently when I was trying to learn JavaScript's prototype-based system without letting my traditional OO knowledge (Java, etc.) get in the way and make it more confusing.

For a slightly less in-depth treatment, I also recommend Pro JavaScript Design Patterns and John Resig's Pro JavaScript Techniques. Both have chapters on the topic.



回答2:

It is important to distinguish between classic OOP and OO JavaScript.

While some languages such as Java, C# and Python are good for learning OO concepts such as classes, objects, inheritance and polymorphism - JavaScript is not one of those languages.

JavaScript can have object-oriented features but through the use of prototypes. It gets more complicated due to the complex data structures.

I think you should define exactly what you are looking after. If it's learning object-oriented concepts, you should go with a classic OO language to learn the basic concepts, and only then continue on to OOJS.



回答3:

Refactoring: Improving the Design of Existing Code by Martin Fowler while the examples are given in Java, the principles behind it are applicable to most OO languages including JavaScript.



回答4:

Definitely worth reading: JavaScript: The Good Parts by Douglas Crockford.

The chapter 5, "Inheritance" covers different types of Object Orientation:

  • Pseudoclassical, simulating Class hierarchies by extending prototype objects with new methods
  • Prototypal, without classes, using prototype objects to create new instances with common functionalities, then attaching new functions to these new objects directly
  • Functional, using constructor functions to create a private scope and return a new object grouping a set of methods with privileged access to the private variables