在ES6之前,将字符串连接到一起的方法是+或者concat()方法,如

const student = { name: 'Richard Kalehoff', guardian: 'Mr. Kalehoff' }; const teacher = { name: 'Mrs. Wilson', room: 'N231' } let message = student.name + ' please see ' + teacher.name + ' in ' + teacher.room + ' to pick up your report card.'; 

模板字面量本质上是包含嵌入式表达式的字符串字面量.
模板字面量用倒引号 ( `` )(而不是单引号 ( '' ) 或双引号( "" ))表示,可以包含用 ${expression} 表示的占位符

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。
let message = `${student.name} please see ${teacher.name} in ${teacher.room} to pick up your report card.`; 

 



作者:Showdy
链接:https://www.jianshu.com/p/87008f4f8513
来源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。
扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄