Embedding the string

String embedded manner

String embedded definition

 

~~~js

`Single quotes for the anti-defined string with the template

let name="koma"

let str = "Hello, $ {name}!" // standard string

let str2 = `Hello, $ {name}!` // string templates

console.log(str)

console.log(str2)

 

function tagged (formats, ... args) {// ... is to expand the operator

  console.log(formats)

  console.log(args)

}

tagged` Hello, $ {name}! `

// output

['Hello there,','! ']

[ 'Come']

Guess you like

Origin www.cnblogs.com/huchong-bk/p/11504432.html