javascript - (_a = [""], _a.raw = [""],....); What does a small bracket mean in js?
为情所困
为情所困 2017-07-05 10:54:56
0
2
878

The code compiled with typescript is as follows:

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}.`;

Compiled 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)); Here are the parentheses, and the ones inside are like parameters. What does it mean? And what is _a.raw?

为情所困
为情所困

reply all(2)
曾经蜡笔没有小新

Execute multiple expressions in brackets

迷茫

You can print template.raw in the test function of the first code, and you should know

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template