This is an error I've never seen before.
Here's a simple repro: https://jsfiddle.net/jakelauer/qr0ysmst/3/
const x = myVar => {
console.log(myVar);
for(let myVar of [1,2,3]){
console.log(myVar);
}
};
x(10);
Output in Chrome: 10
, 1
, 2
, 3
Output in Safari: SyntaxError: Cannot declare a let variable twice: 'myVar'.
Ideas? Is this a bug in Safari?
Edit - Worth noting, I wouldn't ever do this on purpose. I noticed it because I use the ASP.NET bundling & minification system, and that system did this (so my site broke in Safari)
Edit 2 - Interestingly, this works in both browsers
let x = 10;
for(let x of [1,2,3])
{
console.log(x);
}
https://jsfiddle.net/jakelauer/aw37pd2s/1/
Looks like it's a Safari bug. I filed a bug report.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With