Javascript framework for emulating OOP [closed]
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:
Defining custom objects in JS. This is done in a manner very much similar to "function" definition, that is where most beginners stumble.
Difference between Function invocation and Constructor style invocation (latter is used in creating objects)
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.
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/
精彩评论