字符串类型

//多行字符串
let title = `aaa
bbb
ccc`;
console.log(title)

//字符串模板
let myname = 'world';
let age = function () { 
    return 18;
}
console.log(`hello ${myname}`);
console.log(`${age()}`);

//自动拆分字符串
function test(template,name,age) { 
    console.log(template);
    console.log(name);
    console.log(age);
}
let myname_a = 'bbb';
let getAge = function () { 
    return 18;
}
// test`my name is ${myname_a},i'm${getAge()}`;
test`${myname_a},${getAge()}`;

posted @ 2018-03-23 18:06  大智如蠢  阅读(73)  评论(0)    收藏  举报