开发者

Javascript framework for emulating OOP [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. 开发者_如何学C Closed 10 years ago.

What javascript OOP frameworks do you use?

I need a library to emulate Javascript OOP programming with constructors, members, properties(public, private), inheritance

Thanks for your answer


Javascript is fully Object Oriented Language, if you didn't know it yet, it means you don't know it well enough. Though some concepts differ from e.g. JAVA, or C# (like inheritance, encapsulation & etc.) they can be successfully simulated (using prototype chaining, closures & etc.).

take a better look at language and you'll find out that no additional emulating is needed to implement OOP behavior in it.


Check out the Prototype framework,

Featuring a unique, easy-to-use toolkit for class-driven development and the nicest Ajax library around, Prototype is quickly becoming the codebase of choice for web application developers everywhere


You may use Coffee Script, a language that 'compiles' to JavaScript.


JavaScript is not an explicit object oriented language. But you can use it to implement all the Object oriented ideas if you know it well. I would suggest looking at following w.r.t JavaScript programming:

  1. Defining custom objects in JS. This is done in a manner very much similar to "function" definition, that is where most beginners stumble.

  2. Difference between Function invocation and Constructor style invocation (latter is used in creating objects)

  3. Assigning member variables to objects. This can be achieved by using "this" keyword in the function definition(will be clear if point 2 is clear). Also "prototype" can be used for the same purpose.

  4. Having private variables in an object: This can be achieved by using "var" keyword for variables declared inside the function (Will be clear if point no 2 is clear).

This site is a very good source to start you off with these concepts: http://javascript.crockford.com/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜