ES6 tagged templates practical usability

You can use tagged templates to build APIs that are more expressive than regular function calls. For example, I’m working on a proof-of-concept library for SQL queries on JS arrays: let admins = sql`SELECT name, id FROM ${users} WHERE ${user => user.roles.indexOf(‘admin’) >= 0}` Notice it has nothing to do with String interpolation; it uses … Read more

Backticks (`…`) calling a function in JavaScript

It is called Tagged Template in ES-6 more could be read about them Here, funny I found the link in the starred section of the very chat. But the relevant part of the code is below (you can basically create a filtered sort). function tag(strings, …values) { assert(strings[0] === ‘a’); assert(strings[1] === ‘b’); assert(values[0] === … Read more