[Javascript] Template literal tag

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"}`

 

posted @ 2024-03-22 02:50  Zhentiw  阅读(1)  评论(0编辑  收藏  举报