I have encounter this example and was completely lost...
const test = (hey) => console.log(hey);
console.log(test `wtf`);
First all this is valid, in the console.log, it appear to be
["wtf", raw: Array[1]]
It's like the function is been executed and with extra raw
? can someone please explain?
It's just a Tagged Template Literal. It looks fancy, but there's nothing too special about it. Note, they're part of ES6/ES2015 so you will need to tranpsile them if you plan on supporting older browsers.
Template literals are string literals allowing embedded expressions. You can use multi-line strings and string interpolation features with them. They were called "template strings" in prior editions of the ES2015 / ES6 specification.