3 ms·
Just my 2 cents: Javascript gives you plenty of rope to hang yourself with. Personally, I try to stay away from prototypical objects unless the style fits very
by irrelative 17y ago
Just my 2 cents: Javascript gives you plenty of rope to hang yourself with. Personally, I try to stay away from prototypical objects unless the style fits very cleanly with what I'm trying to do. Otherwise,the best way I've found to keep my sanity is to pick whatever language you're developing the backend with, and use as many conventions you've established there as possible.
For me, this means my Javascript looks more like Python -- it can be a little weird, but switching between the frontend and the backend is easier that way.
I'd also recommend using objects as namespaces if you're not dealing with prototypical objects. It makes grepping easier - you can search for 'Graphs.init' instead of 'init' in this example:
var Graphs = {
state_variable: null, // store global state somehow
init: function() {
// Some initialization code
},
refresh: function(img_element, url) {
// some code to refresh the src url
}
};