Object Oriented Javascript

后端 未结 5 938
Happy的楠姐
Happy的楠姐 2020-12-13 07:56

In the course of programming we encounter large javascript files which are open source and written in an object oriented manner( like JQuery ).

If we need to modify

相关标签:
5条回答
  • 2020-12-13 08:15

    First of all I think that you have to understand how JavaScript object orientation works, JavaScript OO is Prototype-based, in which classes are not present, and behavior reuse is implemented by prototyping.

    I've seen that this can be hard to catch at the beginning for programmers that have been working on conventional class-based object-oriented languages (like C++, C#, Java, etc).

    Recommended articles:

    • Introduction to Object-Oriented JavaScript
    • JavaScript: The World's Most Misunderstood Programming Language
    • Classical Inheritance in JavaScript
    • Private Members in JavaScript
    • Class-Based vs. Prototype-Based Languages
    0 讨论(0)
  • 2020-12-13 08:18

    There are two things I would do:

    1. Read. If there's documentation files, read those. If there's comments, read those. If neither of those help you, then go to the source and read that.

    2. When you talk about open source Javascript, I assume you mean this JS is collected into some kind of project; all client-side JS is open source :P. In that case, the authors may be willing to tell you about their code. Locate their email on the project page, and ask them to give you a high-level overview of the code so you can start reading it and understanding it yourself. They probably won't be willing to hold your hand through the entire thing, but having that as a starting point would probably help.

    0 讨论(0)
  • 2020-12-13 08:29

    I agree with allyourcode there's no magic trick. You have to read the code and read the docs. And if the docs are no good, maybe you should think about using a different framework.

    0 讨论(0)
  • 2020-12-13 08:35

    I have a copy of

    • Javascript: The Good Parts

    and

    • Javascript: The Definitive Guide

    sitting on my desk right now. Incidentally these are the only two Javascript books which Douglas Crockford thinks are any good ;)

    They'll teach you how Javascript works, specifically how its object model is different to most (but not all) other object-oriented languages.

    Other than that, do check out all the articles on Crockford's website, as have already been mentioned in other answers.

    0 讨论(0)
  • 2020-12-13 08:35

    A good start is in understanding the difference between traditional OO and Javascript's Prototype model. (Crockford has some articless that implement traditional OO for Javascript in order to contrast the behaviors.)

    0 讨论(0)
提交回复
热议问题