Classes in JacaScript? There’s a way

I was messing with my game prototype when something came along: how do I create objects in this thing? Many of the examples I’ve seen were quite weird, with functions creating new instances of things and being used to define objects. But what about real classes? Inheritance? After all, is there a standard in JavaScript?

Looks like it doesn’t, and many approaches seem to consist in implementing custom sugar functionality or using some weird techniques (from a C++/Java/Python developer’s point of view). I still want to check the examples to establish a memory footprint, because, apart from “static” (in JavaScript, prototype) functions there is no such thing as static beside a “global variable” (that might even contain a function). JavaScript is indeed an easy but weird language. 🙂

Anyway, my project was pushed to GitHub today, there is some basic functionality but not much beside some test bench. I’m working now to reach an architectural model for my objects with shallow inheritances to assure it “stays small” and following some best practices. The JavaScript/HTML5 Netbeans plugin is awesome! Also took some time to try jVI again, I’m more productive with it even with its performance penalty.

 

Comment this