Hacker News new | ask | show | jobs
by xigoi 735 days ago
What’s wrong with top-level functions (as opposed to methods)? Is there a meaningful difference between foo(bar) and bar.foo()?
1 comments

Same reasons JS has modules that don't export everything, and for the same reason that React reinvented OOP under a different syntax with function components. Encapsulation, API design, runtimes and IDEs all work a lot better if the tools are aware of the link between the data and the code that's manipulating it.