When using a for of loop, both of these are allowed and work:
const numbers = [1,2,3];
// works
for(let number of numbers) {
console.log(number);
}
// also works
for(const number of numbers) {
console.log(number);
}
Run Code Online (Sandbox Code Playgroud)
I always use const since I annot fanthom changing the number variable in any context, but when I see a for...of loop in other people's code, it often uses let. Maybe there's a drawback to const that I didn't see? Browser bugs?
为什么在循环中使用 …
场景:您想知道是否正在使用TURN服务器进行特定呼叫,以及是否正在使用您在创建PeerConnection期间提供的TURN服务器阵列中的哪一个.现在有两种选择:
我想使用上面两个的替代方法,以编程方式确定这一点,所以我不必离开我的应用程序页面.