DEV Community

Pacharapol Withayasakpunt
Pacharapol Withayasakpunt

Posted on

2 1

Why do many Javascript libraries or documentations keep using callback, var, == or function keywords?

Despite being recently updated. Without support for arrow functions, of course.

Or, the authors are experienced and immune to callback hell? No, the libraries aren't for noobs.

They are just being experienced with the old ways, and wouldn't create bugs, anyways.

Top comments (1)

Collapse
 
lexlohr profile image
Alex Lohr
  • callback: a many libraries aim to be isomorphic, i.e. work both on node as well as in the browser, the former coming with a strong preference for callback patterns (and a utility to promisify functions adhering to that pattern).
  • var: if you want to support browsers older than IE11, you'll have to use var instead of const and let; of course, you can use a transpiler to support them, but then you'll give up part of the control you have over your code and not everyone wants that.
  • ==: In some cases, you explicitly want your comparisons to coerce other types; yes, you could manually coerce them and use a typesafe comparison, but you don't need to.

You could also ask why people are using || if ?? is available. Sometimes, the choice was made consciously. Also, many of these libraries are around for longer than 5 years and thus had no arrow functions when the documentation was written.

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay