Things I miss the most in JS/ES6+

Now that ES6 and further are out and available to use (eventually compiled by babel), it has become much more comfortable to write Javascipt code. And that’s lucky because it now is by far the most widely used programming language on the github platform.

I like front-end development very much, so I must appreciate writing Javascript code. And I do now that I can use the ES6 syntax almost everywhere. Among the most comfortable features out there, there are:

But writing more and more functional code (in Haskell, Elixir) makes me realize that some basic features lack for JS to embrace the functional paradigm really well. Here are my top ES6 lacks ordered by importance order:

#6 : A wider standard library

Array

Since ES6 introduced array’s map and reduce, and all their siblings, I don’t think any other utilities were introduced in the Array class.

As a consequence, in most of my projects, I need to create a utils/array.js file that would include:

array.first(); // more readable than array[0]
array.last(); // more readable than array[array.length -1]
array.contains(el); // more readable than array.indexOf(el) > -1

NB: depending on the mood, I will or not extend the Array.prototype class.

String

I also most regularly need some string utilities, like:

string.startsWith(start); // more readable than string.indexOf(start) === 0
string.endsWith(end); // more readable than string.indexOf(end) === string.length - end.length;
string.prepend(prefix);
string.append(suffix);

Object

The Object type is much more abstract hence usage can really vary and it may not make sense to expand the standard library too much on those usage specific cases, but on every JS project I have, I only add:

Lodash.get

which basically safely accesses a value in an object (or an array, which makes it tricky for prototyping),

Read Further

How to display comments on a web page
Last Update Feb 5, 2019 | Language

Comments replies are too often not correctly hierarchised

Continue →
My own React vs. Angular
Last Update Nov 11, 2015 | Language

Comparing the two frameworks inner architecture

Continue →

Comment