Have you tried using let to set the scope of date? e.g.
for (let date of dates) {
console.log(date);
}
This blog might help. Personally I would stick with the forEach implementation as I find it more readable.
I just moved some JavaScript code from a Blade file to a separate JavaScript file in the assets/js directory. I use Laravel Mix without any modifications (my devDependencies contain "laravel-mix": "^2.0", and I run npm run dev to compile my assets).
Something in this process is breaking my code, more precisely this for ... of loop inside a Vue method:
for (date of dates) { // date is undefined in this line already)
console.log(date);
}
This variation using forEach is working:
dates.forEach(function(date) {
console.log(date);
});
What is happening here?
Have you tried using let to set the scope of date? e.g.
for (let date of dates) {
console.log(date);
}
This blog might help. Personally I would stick with the forEach implementation as I find it more readable.
Please or to participate in this conversation.