I saw this in a codepen "http://codepen.io/jalabkhan/pen/bgNavG". I am confused about how the foreach loop works. Also what is the value of spark, i and array. I am new to programming so please try to make the answer as simple as possible. Thanks Everyone!!
function draw() {
ctx.fillStyle = 'rgba(0,0,0, 0.1)';
ctx.fillRect(0, 0, ctx.canvas.width, ctx.canvas.height);
sparks.forEach(function (spark, i, array) {
if (spark.opacity <= 0) {
array.splice(i, 1);
} else {
drawSpark(spark);
}
});
window.requestAnimationFrame(draw);
}