Are the class in jQuery?

0

I would like to know if there is something similar to this in jQuery

class Area{
public function data(){
}
}
    
asked by Máxima Alekz 14.08.2016 в 19:20
source

2 answers

2

If you want to use classes you have to use EcmaScript 2016 in which if the classes exist use a transpiler like Babel JS that goes from ecmascript version 5 to ecmascript2016 is easy to use a tutorial_: link babel comes by modules depending on what you want to use if you want classes using the class module, or the functions or the string templates IN JQUERY in its latest version you still can not use classes like you want to still can not

    
answered by 14.08.2016 в 22:00
1

jQuery is not a language, it is a library or "framework" - the language is Javascript.

In Javascript there are no classes, properly speaking. It is an object-oriented language, but not through classes but through prototypes.

Anyway, there are several patterns that are pretty similar to what we come from Java / C ++ / Php / Python / C # we are more used to. The common thing is to define the skeleton of this pseudo-class in a function (by convention, it starts in uppercase) that will work as a kind of constructor of new objects, when it is called with new . Example:

function Usuario() {

    var nombre = "";

    this.getNombre = function() {
         return this.nombre;
    };
}

var u1 = new Usuario();
var u2 = new Usuario();
    
answered by 14.08.2016 в 20:42