Arrow Functions in ES6

Arrow functions have been introduced to Javascript as a more concise way to write function expressions. Here are some examples of the syntax.  Instead of this old-style regular function we can write We can drop the function keyword, and if just returning an expression, we can drop the return keyword, too.  If there is only […]

ES6 Content Literals

The Data Storage custom Drupal module uses Javascript to dynamically generate HTML to present a variable number of questions and services. Writing HTML is Javascript has always been pretty clunky, full of hard to read expressions like this: For heavier template lifting, I’ve been using the Mustache Javascript library.  Templating libraries like Handlebars (which I […]

Rest and Spread

Rest and spread are two new operators in the new ES6 (ECMAScript 6) standard which Javascript implements.  Javascript development in Drupal 8 Core is now done in ES6.  See: https://www.drupal.org/node/2815083 Both Rest and Spread are represented with 3 dots (…). REST (“the rest of the parameters”) is used in function calls where you want to treat an […]