You can. You just can't use it like that, because there is no forEach
property on the HTMLFormControlsCollection that form.elements gives you (which isn't an array).
Here's how you can use it anyway:
Array.prototype.forEach.call(form.elements, function(element) {
// ...
});
Or you may be able to use spread notation:
[...elements].forEach(function(element) {
// ...
});
...but note that it relies on the HTMLFormControlsCollection
implementation in the browser being iterable.
Or alternately Array.from
(you'd need a polyfill for it, but you tagged ES2015, so...):
Array.from(elements).forEach(function(element) {
// ...
});
For details, see the "array-like" part of my answer here.