Doubt when instantiating object in javascript

Asked

Viewed 113 times

0

I have the following line in my code:

document.all['grid_tipo_prestador_' + ind_operadora].object = new _gridlist(document.all['grid_tipo_prestador_' + ind_operadora]);

I confess, I have no idea where it comes from _gridlist. See that I have one new _gridlist(...), now that _gridlist in this file only appears on this line and in the other files, both in the caller and in the auxiliary there is this guy. How can I give a new one that way? When we use C#, we give a new one in an existing class, now in Javascript I don’t know what happens here. As Javascript is very dynamic and its object orientation is a little different from C#, suddenly it allows you to create a type dynamically, different from C# that I need to instantiate a previously existing class. I’d like to understand that.

  • technically Javascript is not object oriented, but prototypes.

  • 1

    pnet, in any of the files *.js must have some kind of statement var _gridlist = function() { ... }, is at this point that the _gridlist is created. If you want to read more about, I advise this the following article

  • @Tobymosque, that’s what I meant and ran away at the time of the post. Being prototype oriented, does this allow the creation of objects dynamically? Because in javascript, I can say that there are no classes?

  • @Tobymosque, you’re right. It’s in the . js file referring to the grid in question. Your comment to me is the answer. I was preceded in posting. I apologize for the rashness.

  • In Ecmascript 5, there is no class definition, so what you can do are objects and understand them using prototypes, in Ecmascript 6 you can create classes, but most modern browsers still don’t have ES6 support

  • @Tobymosque, man once again you saved my homeland. Thank you. As I said, your comment that is voted, solved my situation.

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.