是的,for-of 循环可以被打断。
你可以使用 break
语句来打断 for-of 循环。例如:
for (const x of [1, 2, 3]) {
if (x > 1) {
break;
}
console.log(x);
}
// 输出: 1
是的,for-of 循环可以被打断。
你可以使用 break
语句来打断 for-of 循环。例如:
for (const x of [1, 2, 3]) {
if (x > 1) {
break;
}
console.log(x);
}
// 输出: 1