I am a bit of a JS noob, but have good .net experience in my pocket.
I am working on a mobile website/app, and I have collected some data similar to business listings from a custom web service.
On .net, I would have, at this time, started building a custom class consisting of a list of other "business-listing-classes". I would then step through each custom object in my list, and use it on the screen.
Two questions:
- Should my javascript approach be different than above?
- Can this be done in Javascript?
I know javascript does not have classes persè, and I know you can have a custom function act as a "class". Am I then just to instantiate a bunch of different versions of said custom function, and add all of it to an array?
I almost have the feeling that I should just stick with them in the json format they are? Or build simple arrays? (From what I've learned from Javascript so far..)
Am I over engineering this? I am not sure what the correct javascript approach is.
classstatement, there will be no class, and under the hood, it will still be prototype inheritance. It will only be syntactic sugar. You can invoke functions as constructors, yes, but that does not make it a class, with a 'contract'. In JS, objects are instantiated from objects (from functions, which are objects), not classes.