Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Nobody needs classes nor prototypes in JS. Objects + functions is more than enough. I stopped using these few years ago and miss nothing.


You and "anybody" are actually two different sets of people with different needs and desires


It is enough, but not more than. Collecting functions in a group by operating on a shared context is naturally useful and convenient. Pretending otherwise leads to all sorts of “a method, but I see it as a function with an accidental first parameter in a homonimous namespace because having a function name prefix is ugly, and it’s all ugly, but at least it’s not a class”.

  import * as fooNs from './foo'
  fooNs.barBazQuuxFoo(foo, …)
vs

  foo.barBazQuux(…)


IDE support is often hit or miss with these, I have seen too much of it.

Don't use vscode or never bother to write jsdoc/do any strict typing? Never mind. Good luck with your codebase.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: