javascript tagged_template_literals

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript tagged_template_literals相关的知识,希望对你有一定的参考价值。

const name = 'Dave'
const position = '10th'
const number = 5

function getMessage(literals, name, position, number){
  console.log(literals)
  console.log(name)
  console.log(position)
  console.log(number)
  
  return literals[0] + name + literals[1] + position + literals[2] + number + literals[3]
}

const message = getMessage`Hello ${name}, you are ${position} in queue ${number}.`
console.log(message)

---

// ['Hello ', ', you are ', 'in queue ', '.']
// Dave
// 10th
// 5
// Hello Dave, you are 10th in queue 5.

以上是关于javascript tagged_template_literals的主要内容,如果未能解决你的问题,请参考以下文章

javascript JavaScript isset()等效: - JavaScript

JavaScript 使用JavaScript更改CSS(JavaScript)

JavaScript之基础-1 JavaScript(概述基础语法)

前端基础-JavaScript的基本概述和语法

JavaScript

JavaScript