So for this random project (another one) I'm working on geocodeing a spreadsheet of addresses and adding them to a map. I'm building with the constructor.prototype stuff that you showed me with Guss and am wondering how far I can extend the prototype for more organization. Say for instance I'd like to split my functions into categories such as "spreadsheet" and "map" where I could essentially do all spreadsheet functions by calling:
this.spreadsheet.get
OR this.spreadsheet.query
OR this.spreadsheet.print_to_dom
and similarly could use my mapping functions like:
this.map.init_tiles
OR this.map.add_points
basically keeping everything scoped within the same set of parent functions instead of all at the same parent constructor level.
Is the best way to to do this by essentially making that first-level prototype function a standard object like:
constructor.prototype.map = {
init_tiles: function () { ... },
add_points: function () { ... },
etc: function etc () { ... }
}
??
It doesn't seem to work by declaring the object literally in stride like constructor.map.add_points
because using this.map.add_points
within the scope results in an undefined error. Is this where I should start using constructor.Class
or something?
I think my confusion came from the
leaflet-src.js
file, which has an actual object namedClass
but the syntax highlighter made it seem like it was something reserved for javascript or something. Where does usingprototype
come in, when I could just not use the word at all? Is this more of an organizational usage rather than purely functional?