5 ms·
Objects 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 mo
by austin-cheney 3y ago
Objects 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.