[Javascript] Template literal tag

Zhentiw發表於2024-03-22
function thankYouTag(arrayOfStrings,firstExpression, secondExpression, ...) {
   console.log(
     arrayOfStrings, // ["This is the first one ", " This is another one ", ""] last empty "" due to expression in the end
     firstExpression, // You are nice!
     secondExpression, // string  
   )
}

const greeting = "You are nice!"
thankYouTag`This is the first one ${greeting} This is another one ${"string"}`

相關文章