node js mysql escape string

JavaScript
// Escape values:

let escaped = mysql.escape('myString');

// or

mysql.query(
  "SELECT * FROM `table` WHERE `str1`=? AND `str2`=?",
  ['myString1', 'myString2'],
  (err, result)=>{}
);

// Escape identifiers:

mysql.query(
  "SELECT * FROM ??",	// note the double ?
  ['tablename'],
  (err, result)=>{}
);
Source

Also in JavaScript: