Always bet on JavaScript
Samuel Batista / December 31, 2021
2 min read • ––– views
I read an interesting article today where a developer documents his journey switching from Ruby to Python.
While not exactly the same, moving from Java, Ruby, C# or some other heavily OOP based language to JavaScript has a lot of similarities. While JS has OOP capabilities, it shines as a functional language, and syntax aside, at its core, is fairly similar to Python (all objects are hashmaps for example, and mostly everything is an object, including functions).
I think this is a good read for anyone struggling / frustrated with JavaScript. JS starts to make sense when you stop thinking in terms of classes & methods, and start thinking in terms functions & data.
Instead of creating complex behaviors using inheritance, you can pass functions to other functions to create more complex behaviors. I created this gist to illustrate this concept.
While you can (and sometimes have to) use classes in JS, it's important to learn the functional approach. Knowing how to use array map & reduce is great, but understanding the concept of passing functions as parameters to other functions in order to compose complex behaviors is what will help you discover the true power of JavaScript.
Happy new year, and remember: Always bet on JavaScript!