Answer the question
In order to leave comments, you need to log in
What JavaScript framework do you recommend that makes it easier to write object-oriented code?
It is planned to start using the JavaScript framework to facilitate writing object-oriented code.
So far, MooTools and JS.Class are candidates.
Maybe there is a clear comparison somewhere?
The project is already using jQuery
Answer the question
In order to leave comments, you need to log in
This comment
comes to mind .
It's almost useless to advise here. All are comfortable.
It is not necessary to use an object framework, it is necessary to write as simple and direct code as possible, because when developing client side code, it is important to minimize the amount of code and its execution time, and secondly, the simplicity and clarity of the code, and all the useless libraries that serve the purpose of enhancing feelings of coolness of the developer, rather than practical purposes, should be removed.
I just used MooTools.Class in parallel with jQuery. Quite a solution.)
I used at one time
github.com/shergin/legacy/ - light and simple
Mootols
ExtJS
Then I realized that OOP in its purest form is not exactly what you need in JS. For simple projects, ordinary prototypes are suitable, for something more complicated, there are either like Backbone.js
Write native classes. Like this:
// класс
Animal = function(name){
this.name = name;
}
Animal.prototype.getName = function(){ return this.name }
// наследование
Cat = function(name,color){
var animal = new Animal(name);
this.color = color;
for(var i in this){ // вместо этого можете использовать jQuery.extend(animal, this)
if({}.hasOwnProperty.call(this,i))
animal[i] = this[i];
}
return animal;
}
Cat.prototype.getColor = function(){ return this.color; }
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question