improve looping javascript code
There are a lot of for loops that can be replaced by either for-in or for-of loops when iterating over a whole array and some simple code cleanup is a port of this MR as well.
Signed-off-by: Matej Starc matej.starc@protonmail.com
Edited by Matej Starc