Earlier quoted context omitted.
> DOM APIs are entirely functional. (Almost) none of the DOM APIs are functional. They are literally `object.methodCall()`
Yes, functional programming can have methods. Methods are functions. OOP is all about polyinstantiation and inheritance. Functional programming is all about functions and input/output, which is entirely what happens in this case. The only OOP here is the method assignment you don’t see: Element.prototype.getElementById = function () {};
DOM APIs are the embodiment of 90s-era OOP. There's literally nothing functional about them. All [1] "functions" are methods defined on very specific objects. You can't even get a proper reference to them without binding them to specific object instances
What exactly is functional about this?
const newDiv = document.createElement("div");
const newContent = document.createTextNode("Hello, world");
newDiv.appendChild(newContent);
const currentDiv = document.getElementById("div1");
document.body.insertBefore(newDiv, currentDiv);
Okay, here's an easier question. What will happen here, and why? const function_reference = document.getElementById;
function_reference("#id");
[1] Technically speaking, not all all. The more recent `fetch` is probably the only piece of browser APIs that can be called functional for some very limited definition of functionalMost (all?) other "global" functions are defined on the instance of the window object: getComputedStyle, getSelection etc.