Home  >  Q&A  >  body text

javascript - (_a = [""], _a.raw = [""],....); What does a small bracket mean in js?

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?

为情所困为情所困2663 days ago845

reply all(2)I'll reply

  • 曾经蜡笔没有小新

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

    Execute multiple expressions in brackets

    reply
    0
  • 迷茫

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

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

    reply
    0
  • Cancelreply