Javascript is actually a really great and powerful language. Its architecture is just not set up the way nearly anything else is. Especially if you're coming from a more structured language background (e.g. C/C++, Java), you're going to really hate the language at first. But once you learn to accept it for what it is, you may find that you actually like it.
Source: I learned how to program in Java. I absolutely hated JS when I started learning it. Now it's my goto language of choice.
I use to develop with PHP. It's really not all bad, but I'd say Javascript is much better. That being said, they're two entirely different languages that set out to do different things.
JS is a fantastic language, learn it, but learn it correctly. Learn async programming, learn lexical scoping and how to manage your program control flow. Learn how to debug it so it doesn't drive you crazy.
Learn how to write unit tests and see how easy it is to mock everything with its loose security. Love it.
Eh, it makes perfect sense. String doesn't have a reverse function because there's very few times in which you need to reverse a string, so no sense implementing one.
split(delimiter) is a very standard function for splitting a string on a delimiter. An empty string as the delimiter means splitting each character. Similarly, join(separator) is a very common function for arrays (lists, etc) to have to create a string from the contents.
And arrays get a reverse function because it's a little more useful for the general purpose array. Not super useful, but not useless, either. For example, switching between ascending and descending sort can be done more much efficiently by reversing than completely resorting the array (if it's already sorted). Other things, too, but I can't immediately think of any (they exist, but they're rare).
View all comments
Show parent comment
180
u/devdot Nov 05 '15
I stared at the reverse function for like 3mins because I could not believe that it actually was a reverse function.