2 ms·
Aren’t 1 and 4 a bit of a contradiction? The DOM is the document object model for a reason - modern JavaScript is fundamentally object-oriented. What alternativ
by mock-possum 3y ago
Aren’t 1 and 4 a bit of a contradiction? The DOM is the document object model for a reason - modern JavaScript is fundamentally object-oriented. What alternative do you propose to OOP JS - functional programming? You can fake it, but why? Why not just go with the flow?
- austin-cheney 3y agoObjects in JavaScript are hashmaps, or structs in Rust, or various other names for the same things in whatever language. More specifically the DOM is a tree model no differently than a file system. It is arranged as an object because that is the data structure chosen by the original implementers, but it could be just about any combination of data structures. Back then the only opinions in JavaScript for data structures were objects and arrays. That is not what OOP is. OOP is about expressing poly-instantiation and therefore allowing inheritance. The internals of JavaScript are fundamentally OOP, such as the type system and distribution of DOM methods each expressed as prototypes. Most of that stuff you shouldn't be touching anyways. As far as your own code OOP is completely optional and requires far greater effort. Functions are first class citizens that can go absolutely anywhere with any kind of nesting in ways OOP structures cannot.