The string statement passed in the string function will report an error without a semicolon.

var str = "console.log("222");console.log(111)";  //
var tempFun = new Function(str);
tempFun();   

then I remove the semicolon between the two sentences

var str = "console.log("222") console.log(111)";  //
var tempFun = new Function(str);
tempFun();   

I don"t quite understand why we can write without a semicolon.

Jun.29,2021

does not add a semicolon, but there is an enter


the following must report an error, you have multiple lines of code here, so you must add a semicolon ";" mark the end, otherwise, the implementation will definitely report a syntax error.


I'm afraid you're crazy.
by not adding a semicolon, we mean the end of the line ah

.
//
console.log('222')console.log(111)console.log(111)
Menu