版权声明:内容多为自言自语,请自行判断有无价值。 https://blog.csdn.net/weixin_41702247/article/details/82813072
function greet(name){
let weather='sunny';
return `Hello ${name}, today is a ${weather} day!`;
}
greet('Tom'); //"Hello Tom, today is a sunny day!"
注:
1.反引号内字符串不需要再用引号
2.插入变量使用${...}
3.可以配合jQuery实现插入html标签,如
$('#list').html(
`<ul>
<li>1</li>
<li>2</li>
</ul>`);
4.{...}内可以放入任意的js表达式(运算、引用对象属性、调用函数