Best Posts of 2018
Each year I make a post about the best posts I think I have for the year that are not in the most popular posts sidebar (on obscurejavascript.tumblr.com as of early January 2019). Since popular doesn't necessarily mean better. The list for 2018 is below:
1. All Objects Have ValueOf This method is available in all objects. It specifies the value of the object when used in numerical operations. For example, the Date object returns the timestamp of the current date so that dates can be subtracted to compare if the time is different and by how much.
2. JavaScripts Console Object (Beyond Logging) JavaScript is generally a very lean language without too much syntactical helpers or much built in functionality. One exception is the console object which provides functionality to track how many times a function is called, time a piece of code and other functions all without using any libraries.
3. Caching Functions Via Memoization If you ensure a functions output is directly determined by its input (referential transparency in Functional Programming), it is easy to cache a functions result after it has been called without custom storage code. Which is very useful to eliminate performance issues on problems like, for example, UI calls that get called on fluid user input like mouse or finger dragging.
4. ES6 Classes Are Just Syntactic Sugar This provides an example of how JS objects were created in the past that could be used as classes and gives a direct translation to what it looks like with the much simpler class syntax.
5. Natural String Sorts In general, doing natural string sorts where capitalization, numbering and so on to make sense to humans is very hard without a library. Fortunately, JS provides this through String.localeCompare which enjoys wide browser support.
Posts of Previous Years
Best Posts Of 2017
Best Posts Of 2016
Best Posts Of 2015













