JavaScript is a modern and backward compatible programming language. I gave this weird definition because JavaScript is being constantly modernised and is maintaining backward compatibility. These two characters are essential to the language. And I wanted to highlight how this two play together. Please note that I am here to share my opinions.
While I was trying to come up with an idea for an article, a question struck me. Is JavaScript a feature-rich or a mess? By mess I don't mean quarky behaviour of JavaScript as it is defined in specification and we all can try to learn it. Buy it I mean that the language simply has so many features. The language offers multiple ways of doing several things. Let's have a look at few of them.
Variable declaration
JavaScript atleast has two ways of defining variables, by using var and by using let and const keywords. New keywords let and const are result of modernising process. While var was present from beginning. I understand that both have their pros and cons but I just wanted to highlight two ways of declaring variables.
Two ways for function declaration
Arrow function is relatively new edition to the language. JavaScript already had old way of defining functions. Both have some differences regarding implementation. But it doesn't matter for very simple use cases.
Addition to class keyword
Recently many keywords like class were added into the language which are related to object oriented programming. We can argue about it's usefulness but the truth is that now we have two ways to work with object oriented code. We can use new keywords and features or we can also use old constructor based approach.
Two API(s) for working with dates
We all know about tricky Date API for working with dates and time in JavaScript. We also have new Temporal API with looks very nice for working with dates. On a side note, I have another problem with this as well. New API may not be compatible with old API. I know we have work around this. But it would be nice if new would support old as well.
So many data structures
I don't have any objections about this as each data structure has unique purpose. but it is true that the language has many data structures with basic once like Object and Array. For example, we have Map, WeakMap, Set and WeakSet. And yes Record & Tuple are coming to the language!
Conclusion
It is very easy to prove that the language is feature-rich. But sometimes it looks like mess of features. one can argue that multiple ways of doing things gives greater flexibility and I completely agree to that. But sometimes it can create confusions as well. Would love to know your opinions!
Top comments (0)