DEV Community

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

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.