Every time I attempt to utilize a for..of loop, I encounter a frustrating "ReferenceError" related to the iterator value.
Despite my efforts to convert the for...of loop into a for...in loop, the issue persists. I have a hunch that it may be connected to either the script tagged as a module, or potentially my utils.js
file. However, even after removing them, the same error persists. This problem occurs specifically on Chrome 76 on Windows 10.
Below is the code in question:
<body>
<canvas id="canvas" width="800" height="600">
Bruh. are you using IE?!
</canvas>
<script type="module">
import { Mouse, Screen } from "./utils.js"
let attractionForce = 1;
let friction = 0.99;
let canvas = document.getElementById("canvas");
let ctx = canvas.getContext("2d");
//let mouse = new Mouse(canvas);
const PI_2 = Math.PI * 2;
var points = Array.from({ length: 1000 }, () => ({
x: Math.random() * 800,
y: Math.random() * 600,
dx: (Math.random() - 0.5),
dy: (Math.random() - 0.5),
}));
for (pti of points) console.log(pti); << Uncaught ReferenceError: pti is not defined
</script>
</body>
Normally, the loop would smoothly iterate over the array, but now it frustratingly throws this error. Any guidance or assistance on this matter would be sincerely appreciated!