Array#random method (we don’t have it), or trying to find how to compare two dates in two different timezones (hope you’re using moment!) or learning there’s no builtin function to reverse a string (hint: make it an array first).
If you find yourself frustrated by all the little idiosyncrasies, it might be good to know that the kind folks that make our language spec are looking out for us. Here’s three upcoming language proposals to keep an eye on if you’re looking for small quality-of-life improvements.
Date object: for projects that want to sidestep having to write their own timezone-aware date comparison functions, but don’t need to
import moment quite yet.
For an example, here’s a snippet from that proposal’s README.
This is such a little thing, but I’m so excited for it. Lots of other dynamic languages have array methods that return the array’s last element, like ruby’s
This proposal will allow us to use a getter property,
someArray.lastItem, to get the last element of an array.
If you’ve written Java, you’re familiar with class definitions that have instance variables defined on them—maybe something that looks like this:
class semantic. If you want to find out what instance variables classes use, you need to trace through the constructor and look through the code for assignments to
With this proposal, though, we can list all our instance variables at the top of the class definition, like this:
Even better news: most TC39 proposals have polyfills attached to them (sadly, not all-new syntax is unfortunately not something that can be polyfilled). If you’re really excited about one of these proposals, you can pull it down right now and get cracking. Be warned, though -polyfills for early-stage proposals tend to move very quickly as the proposal is evolving.