2 ms·
Self taught more than a decade ago. JavaScript is my first programming language. In the language you can expressively use and pass around functions anywhere no
by austincheney 6y ago
Self taught more than a decade ago. JavaScript is my first programming language. In the language you can expressively use and pass around functions anywhere no differently than primitives.
Nesting functions provided a necessary structure that both includes containment and reference. At the time JavaScript did not have block scope, modules, or native classes. Also taking advantage of lexical scope in favor of prototypes/inheritance resulted in slightly faster execution. Really, for me, it was more about taking full advantage of lexical scope more than concern for what the function returned as a value.
I would see other people attempt to fake classes in the language and it was atrocious. First of all the code was ugly, but worse is that there absolutely no benefit to this. Clearly these other developers were just just trying to mimic some conventions they use in other languages without learning how to organize their code. That is the opposite of elegant and I didn’t want anything to do with it.