Fix syntax error in print_demo.html caused by CRLF and backslash string continuation

This commit is contained in:
844143714@qq,com 2026-04-30 02:11:43 +08:00
parent ab6b243489
commit ecac48eb4c
1 changed files with 13 additions and 12 deletions

View File

@ -525,18 +525,19 @@
// ES6 特性测试函数(通过 eval 避免阻塞旧版 JS 引擎整体解析)
function testES6Features() {
try {
eval("\
const arr = [1, 2, 3];\
const [a, ...rest] = arr;\
let sum = rest.reduce((acc, val) => acc + val, 0);\
const myMap = new Map();\
myMap.set('key', `Sum is ${sum}`);\
new Promise((resolve) => {\
setTimeout(() => resolve(myMap.get('key')), 100);\
}).then(res => {\
alert(`ES6 引擎测试成功!\\n解构: a=${a}\\nPromise/Map 返回: ${res}`);\
});\
");
var code = [
"const arr = [1, 2, 3];",
"const [a, ...rest] = arr;",
"let sum = rest.reduce((acc, val) => acc + val, 0);",
"const myMap = new Map();",
"myMap.set('key', `Sum is ${sum}`);",
"new Promise((resolve) => {",
" setTimeout(() => resolve(myMap.get('key')), 100);",
"}).then(res => {",
" alert(`ES6 引擎测试成功!\\n解构: a=${a}\\nPromise/Map 返回: ${res}`);",
"});"
].join("");
eval(code);
} catch(e) {
alert("ES6 测试失败 (当前环境可能不支持): " + e.message);
}