Advertisement
njdennis94

JS String Template Tutorial 1/4

Aug 1st, 2018
409
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'use strict'
  2. /*
  3.    The following will generate an SQL SELECT statement.
  4. */
  5.  
  6. function sql(string, column, table){
  7.     return `${string[0]}${column]${string[1]}${table}#{string[2]}`
  8. }
  9.  
  10. let column = 'name';
  11. let table = 'users';
  12.  
  13. sql`SELECT ${column} FROM ${table};` // SELECT name FROM users;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement