Modernize ES for-loops and remove problematic for-in loops

This slightly modifies the behaviour of errors (see init.js)

Change-Id: I1aab691d5b7e8167b6213378bdd9139c133202cd
diff --git a/dev/js/src/vc/docgroup.js b/dev/js/src/vc/docgroup.js
index 3a22034..af49191 100644
--- a/dev/js/src/vc/docgroup.js
+++ b/dev/js/src/vc/docgroup.js
@@ -117,14 +117,13 @@
 
 	      // Flatten group
 	      if (docGroup.operation() === this.operation()) {
-	        for (var op in docGroup.operands()) {
-	          op = docGroup.getOperand(op);
+          docGroup.operands().forEach(function(op) {
 	          var dupl = this._duplicate(op);
 	          if (dupl === null) {
 	            this._operands.push(op);
 	            op.parent(this);
 	          };
-	        };
+	        }, this);
 	        docGroup._operands = [];
 	        docGroup.destroy();
 	        return this;
@@ -275,11 +274,10 @@
 	          this._operands.splice(i, 1);
 
 	          // Inject new operands
-	          for (var op in newOp.operands().reverse()) {
-	            op = newOp.getOperand(op);
+            newOp.operands().reverse().forEach(function(op) {
 	            this._operands.splice(i, 0, op);
 	            op.parent(this);
-	          };
+	          }, this);
 	          // Prevent destruction of operands
 	          newOp._operands = [];
 	          newOp.destroy();
@@ -337,10 +335,7 @@
       };
 
       // Add all documents
-      for (var i in json["operands"]) {
-	      var operand = json["operands"][i];
-	      this.append(operand);
-      };
+      json["operands"].forEach(i => this.append(i));
       
       return this;
     },
diff --git a/dev/js/src/vc/fragment.js b/dev/js/src/vc/fragment.js
index f0c1397..ccc121e 100644
--- a/dev/js/src/vc/fragment.js
+++ b/dev/js/src/vc/fragment.js
@@ -142,9 +142,7 @@
         root.setAttribute('class','docGroup');
         root.setAttribute('data-operation', 'and');
 
-        for (let i in this._operands) {
-          root.appendChild(_doc(this._operands[i]));
-        };
+        this._operands.forEach(i => root.appendChild(_doc(i)));
       }
       else if (l == 1) {
         root = _doc(this._operands[0]);
diff --git a/dev/js/src/vc/menu.js b/dev/js/src/vc/menu.js
index 0f0d92a..f2f4b2f 100644
--- a/dev/js/src/vc/menu.js
+++ b/dev/js/src/vc/menu.js
@@ -44,11 +44,9 @@
      * VCs and small key lists.
      */
     typeOf : function (key) {
-      for (i in this._items) {
-        if (this._items[i].key() === key) {
-          return this._items[i].type();
-        }
-      };
+      const found = this._items.find(i => i.key() === key);
+      if (found)
+        return found.type();
     }
   };
 });
diff --git a/dev/js/src/vc/rewritelist.js b/dev/js/src/vc/rewritelist.js
index 9a87e4e..75f3d27 100644
--- a/dev/js/src/vc/rewritelist.js
+++ b/dev/js/src/vc/rewritelist.js
@@ -37,9 +37,8 @@
       this._element = document.createElement('div');
       this._element.setAttribute('class', 'rewrite');
       var comments = [];
-      for (var x in this._list) {
-	      var rewrite = this._list[x];
-
+      this._list.forEach(function(rewrite) {
+	    
         // This is a blind element
 	      var span = document.createElement('span');
 
@@ -60,7 +59,7 @@
         comments.push(rewriteText + ' (' + rewrite.operation() + ')');
         
 	      this._element.appendChild(span);
-      };
+      }, this);
       this._element.setAttribute("title", comments.join("\n"))
       return this._element;
     }