EcmaScript 6 Features 1: String Interpolations

Welcome to a new series of short posts on the new features of EcmaScript 6. EcmaScript is the technical name for Javascript - and currently I have been writing in version 5. Since version 6 is gaining support quickly, I think it is time that I learnt about all the new features.

This series will be conducted using the latest version of io.js. I will not be investigating features that don't have support in io.js.

First up: String Interpolation. This is just a fancy name for inserting the contents of variables into strings. PHP has this already:

$total = 456;
echo("Total: $total");

Results in:

Total: 456

Now this is coming to Javascript. If you use the %60 (back-tick) character to open and close your strings, you can insert the values of things into a string with ${}:

var name = "Orange";

console.log(`Name: ${name}`);


Name: Orange

You can also use this to pull the values from an object, too. I have recorded a demo with asciinema:

I have also written a test for your browser:

Next up will probably be generators (which are really cool by the way). These posts will also be the first to stick to a (semi) formal schedule: A new one will come out every Tuesday.

Tag Cloud

3d 3d printing account algorithms android announcement architecture archives arduino artificial intelligence artix assembly async audio automation backups bash batch blog bookmarklet booting bug hunting c sharp c++ challenge chrome os cluster code codepen coding conundrums coding conundrums evolved command line compilers compiling compression containerisation css dailyprogrammer data analysis debugging demystification distributed computing documentation downtime electronics email embedded systems encryption es6 features ethics event experiment external first impressions future game github github gist gitlab graphics hardware hardware meetup holiday holidays html html5 html5 canvas infrastructure interfaces internet interoperability io.js jabber jam javascript js bin labs learning library linux lora low level lua maintenance manjaro network networking nibriboard node.js operating systems own your code pepperminty wiki performance phd photos php pixelbot portable privacy problem solving programming problems projects prolog protocol protocols pseudo 3d python reddit redis reference releases rendering resource review rust searching secrets security series list server software sorting source code control statistics storage svg talks technical terminal textures thoughts three thing game three.js tool tutorial twitter ubuntu university update updates upgrade version control virtual reality virtualisation visual web website windows windows 10 xmpp xslt


Art by Mythdael