[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 @   Zhentiw  阅读(1)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示