搜索

首页  >  问答  >  正文

javascript - (_a = [""], _a.raw = [""],....); js一个小括号的是什么意思?

用typescript编译出来的代码,如下:

typescript:

function test(template, name, age) {
    console.log(template);
    console.log(name);
    console.log(age);
}
let myname: string = "Keyon";
let myage: number = 18;
test`Hello, my name is ${myname}, I'm ${myage}.`;

编译后的javascript:

function test(template, name, age) {
    console.log(template);
    console.log(name);
    console.log(age);
}
var myname = "Keyon";
var myage = 18;
(_a = ["Hello, my name is ", ", I'm ", "."], _a.raw = ["Hello, my name is ", ", I'm ", "."], test(_a, myname, myage));
var _a;

(_a = ["Hello, my name is ", ", I'm ", "."], _a.raw = ["Hello, my name is ", ", I'm ", "."], test(_a, myname, myage));这里直接一个小括号,里边的像参数一样的,是什么意思?还有那个 _a.raw 是什么?

为情所困为情所困2700 天前881

全部回复(2)我来回复

  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-07-05 10:56:56

    括起来执行多个表达式

    回复
    0
  • 迷茫

    迷茫2017-07-05 10:56:56

    你可以在第一段代码的test函数内打印下template.raw,应该就知道了

    回复
    0
  • 取消回复