Exploring a Programming Language

As a programmer, it’s important to understand the ins and outs of whatever language and libraries you use. Misunderstanding how the underlying technology behaves is a sure recipe for creating bugs.

In his comically genius “WAT” video,[17] Gary Bernhardt demonstrates how illogical JavaScript and Ruby can be. It’s a fantastic example of exploring programming languages to discover quirks and surprises that can bite the unwary programmer.

Inspired by the video, I decided to explore the JavaScript sort() function. I began with a simple case:

 
[​"b"​, ​"c"​, ​"a"​].sort()

This returned the results I expected:

 
a,b,c

So far so good. I began brainstorming things I could vary: the count of items in the array (Zero, ...

Get Explore It! now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.