This is a mistake that I have never seen before.
Here's a simple replay: https://jsfiddle.net/jakelauer/qr0ysmst/3/
const x = myVar => {
console.log(myVar);
for(let myVar of [1,2,3]){
console.log(myVar);
}
};
x(10);
Exit to the Chrome: 10, 1, 2, 3
output in Safari:SyntaxError: Cannot declare a let variable twice: 'myVar'.
Ideas? Is this a bug in Safari?
Edit - It is worth noting that I will never do this on purpose. I noticed this because I use the ASP.NET build and minimize system, and this system did it (so my site crashed on 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/
source
share