diff --git a/dev/js/src/init.js b/dev/js/src/init.js
index 4482316..4b19b7e 100644
--- a/dev/js/src/init.js
+++ b/dev/js/src/init.js
@@ -96,14 +96,13 @@
      * Release notifications
      */
     if (KorAP.Notifications !== undefined) {
-      var n = KorAP.Notifications;
-      for (var i = 0; i < n.length; i++) {
-        var msg = n[i][1];
-        if (n[i][2]) {
-          msg += '<code class="src">'+n[i][2]+'</code>';
+      KorAP.Notifications.forEach(function(n) {
+        var msg = n[1];
+        if (n[2]) {
+          msg += '<code class="src">'+n[2]+'</code>';
         };
-        alertifyClass.log(msg, n[i][0], 10000);
-      };
+        alertifyClass.log(msg, n[0], 10000);
+      });
     };
 
     /**
@@ -145,14 +144,11 @@
     /**
      * Add actions to match entries
      */
-    var li = d.querySelectorAll(
+    var matchElements = d.querySelectorAll(
       '#search > ol > li'
     );
-    var matchCount = 0;
 
-    for (matchCount = 0; matchCount < li.length; matchCount++) {
-
-      let e = li[matchCount];
+    matchElements.forEach(function(e) {
 
       // Define class for active elements
       if (e.classList.contains('active')) {
@@ -190,7 +186,7 @@
           };
         });
       };
-    };
+    }, this);
     
     // Add focus listener to aside
     var aside = d.getElementsByTagName('aside')[0];
@@ -284,7 +280,7 @@
      * There is more than 0 matches, so allow for
      * alignment toggling (left <=> right)
      */
-    if (matchCount > 0)
+    if (matchElements.length > 0)
       resultPanel.addAlignAction();
 
     KorAP.Panel['result'] = resultPanel;
@@ -441,9 +437,7 @@
       try {
       
         // Register all plugins
-        for (var i = 0; i < p.length; i++) {
-          KorAP.Plugin.register(p[i]);
-        }
+        p.forEach(i => KorAP.Plugin.register(i));
       }
       catch (e) {
         KorAP.log(0, e);
diff --git a/dev/js/src/match.js b/dev/js/src/match.js
index 7ce2652..4f5aedf 100644
--- a/dev/js/src/match.js
+++ b/dev/js/src/match.js
@@ -97,18 +97,18 @@
       };
 
       // Iterate over info layers
-      for (var i = 0; i < this.available.length; i++) {
-        var term = this.available[i];
+      let layer;
+      this.available.forEach(function(term){
 
         // Create info layer objects
         try {
-          var layer = require('match/infolayer').create(term);
+          layer = require('match/infolayer').create(term);
           this._avail[layer.type].push(layer);
         }
         catch (e) {
-          continue;
+          return;
         };
-      };
+      }, this);
       
       return this;
     },
diff --git a/dev/js/src/match/corpusByMatch.js b/dev/js/src/match/corpusByMatch.js
index 43048a3..92d219a 100644
--- a/dev/js/src/match/corpusByMatch.js
+++ b/dev/js/src/match/corpusByMatch.js
@@ -66,9 +66,10 @@
         return;
       };
 
-      for (let doc of this._fragment.documents()) {
+      
+      for (const doc of this._fragment.documents()) {
         vc.addRequired(doc);
-        console.log("Add " + doc.toQuery());
+        // console.log("Add " + doc.toQuery());
       };
 
       if (!vc.isOpen()) {
diff --git a/dev/js/src/match/meta.js b/dev/js/src/match/meta.js
index 78b1430..3cc7512 100644
--- a/dev/js/src/match/meta.js
+++ b/dev/js/src/match/meta.js
@@ -50,10 +50,8 @@
       // Copy original array position to object
       // before sorting by key title
       let posInMetaArray = {};
-      for (let i = 0; i < fields.length; i++) {
-        posInMetaArray[fields[i]["key"]] = i;
+      fields.forEach((f,i) => posInMetaArray[f["key"]] = i);
 
-      };
       
       // TODO: Meta fields should be separated
       // Sort all meta keys alphabetically
@@ -82,18 +80,17 @@
           metaDD.setAttribute('data-type', field["type"]);
 
           if(metaDescr instanceof Array){
-        	  metaDD.classList.add("metakeyvalues");  
-        	  for (i = 0; i < metaDescr.length; i++){
-
+        	  metaDD.classList.add("metakeyvalues");
+            metaDescr.forEach(function(md) {
               if (field["type"] === 'type:attachement') {
-                let att = attClass.create(metaDescr[i]);
+                let att = attClass.create(md);
                 if (att)
         	        metaDD.addE('div').appendChild(att.inline());
               }
               else {
-        	      metaDD.addE('div').addT(metaDescr[i]);
+        	      metaDD.addE('div').addT(md);
               }
-        	  } 
+        	  });
           }
           else{
             if (field["type"] === 'type:attachement') {
diff --git a/dev/js/src/match/querycreator.js b/dev/js/src/match/querycreator.js
index fa4917b..f3c533f 100644
--- a/dev/js/src/match/querycreator.js
+++ b/dev/js/src/match/querycreator.js
@@ -229,9 +229,10 @@
 
               // Is a key-value-cell
               if (sib.classList.contains('matchkeyvalues')) {
-                var divs = sib.getElementsByTagName('div');
-                for (var j = 0; j < divs.length; j++) {
-                  var keyvaluepair = divs[j];
+
+                Array.from(
+                  sib.getElementsByTagName('div')
+                ).forEach(function(keyvaluepair){
 
                   // Get annotation value from cell
                   var annotation = _getAnnotation(prefix, keyvaluepair);
@@ -242,7 +243,7 @@
                     this._addToToken(i, annotation);
                     keyvaluepair.classList.add('chosen');
                   };
-                };
+                }, this);
               }
 
               // Normal cell
@@ -371,6 +372,8 @@
       var str = '';
       var distance = 0;
 
+      // This needs to take undefined tokens into account, therefore
+      // forEach() is not an option
       for (var i = 0; i < this._query.length; i++) {
         var token = this._query[i];
 
diff --git a/dev/js/src/match/table.js b/dev/js/src/match/table.js
index 9078780..92d4e5a 100644
--- a/dev/js/src/match/table.js
+++ b/dev/js/src/match/table.js
@@ -215,15 +215,17 @@
 
           // There are multiple values to add
           c.classList.add('matchkeyvalues');
-          for (var n = 0; n < value.length; n++) {
-            var e = c.addE('div');
-            e.addT(value[n]);
 
-            var anno = ah.getDesc(key, value[n]);
+          let e, anno;
+          value.forEach(function(v) {
+            e = c.addE('div');
+            e.addT(v);
+
+            anno = ah.getDesc(key, v);
 
             if (anno)
               e.setAttribute("title", anno);
-          };
+          });
         }
 
         else {
@@ -272,29 +274,29 @@
 
       var foundryList = Object.keys(this._foundry).sort();
 
-      for (var f = 0; f < foundryList.length; f++) {
-        var foundry = foundryList[f];
-        var layerList =
+      let layerList, key, v, value, cell;
+      
+      foundryList.forEach(function(foundry) {
+        let layerList =
             Object.keys(this._foundry[foundry]).sort();
 
-        for (var l = 0; l < layerList.length; l++) {
-          var layer = layerList[l];
+        layerList.forEach(function(layer) {
+
           tr = tbody.addE('tr');
           tr.setAttribute('tabindex', 0);
           tr.addCell = addCell;
-
           tr.addCell('th', undefined, foundry);
           tr.addCell('th', undefined, layer);
 
-          var key = foundry + '/' + layer + '=';
+          key = foundry + '/' + layer + '=';
 
-          for (var v = 0; v < this.length(); v++) {
+          for (v = 0; v < this.length(); v++) {
 
             // Get the cell value
-            var value = this.getValue(v, foundry, layer);
+            value = this.getValue(v, foundry, layer);
 
             // Add cell to row
-            var cell = tr.addCell(
+            cell = tr.addCell(
               'td',
               key,
               value 
@@ -304,8 +306,8 @@
               cell.classList.add('mark');
             };
           };
-        };
-      };
+        }, this);
+      }, this);
       
       // Add query creator
       this._matchCreator = matchQueryCreator.create(this._element);
diff --git a/dev/js/src/match/treearc.js b/dev/js/src/match/treearc.js
index 2acda9b..e7d7ac3 100644
--- a/dev/js/src/match/treearc.js
+++ b/dev/js/src/match/treearc.js
@@ -99,7 +99,7 @@
     _parse : function (parent, children, mark) {
 
       // Iterate over all child nodes
-      children.forEach(function(c) {
+      Array.from(children).forEach(function(c) {
 
         // Element node
         if (c.nodeType == 1) {
@@ -723,8 +723,7 @@
     var stack = [];
 
     // Iterate over all definitions
-    for (var i = 0; i < list.length; i++) {
-      var current = list[i];
+    list.forEach(function(current) {
 
       // Check the stack order
       var overlaps = 0;
@@ -766,7 +765,7 @@
       stack.sort(function (a,b) {
         b.overlaps - a.overlaps
       });
-    };
+    });
 
     return stack;
   };
diff --git a/dev/js/src/match/treehierarchy.js b/dev/js/src/match/treehierarchy.js
index 0a7bf49..9fc2480 100644
--- a/dev/js/src/match/treehierarchy.js
+++ b/dev/js/src/match/treehierarchy.js
@@ -287,14 +287,14 @@
             if (v.class === "leaf") {
               text.setAttribute('title', vLabel);
 
-              var labelPart = vLabel.split(" ");
-              var n = 0;
-              for (var i = 0; i < labelPart.length; i++) {
-                if (labelPart[i].length === 0)
-                  continue;
+              let n = 0;
+              let tspan;
+              vLabel.split(" ").forEach(function(p) {
+                if (p.length === 0)
+                  return;
 
-                var tspan = that._c('tspan');
-                tspan.appendChild(d.createTextNode(labelPart[i]));
+                tspan = that._c('tspan');
+                tspan.appendChild(d.createTextNode(p));
                 if (n !== 0)
                   tspan.setAttribute('dy', LINEHEIGHT + 'pt');
                 else
@@ -302,7 +302,7 @@
                 tspan.setAttribute('x', v.x - v.width / 2);
                 y += LINEHEIGHT;
                 text.appendChild(tspan);
-              };
+              });
 
               y += LINEHEIGHT;
 
diff --git a/dev/js/src/menu.js b/dev/js/src/menu.js
index 98204ea..4d80419 100644
--- a/dev/js/src/menu.js
+++ b/dev/js/src/menu.js
@@ -206,7 +206,7 @@
       if (this.prefix().length <= 0) {
 
         // add all items to the list and lowlight
-        var i = 0;
+        let i = 0;
         for (; i < this._items.length; i++) {
           this._list.push(i);
           this._items[i].lowlight();
@@ -228,25 +228,22 @@
 
       // Iterate over all items and choose preferred matching items
       // i.e. the matching happens at the word start
-      for (pos = 0; pos < this._items.length; pos++) {
+      this._items.forEach(function(it, pos){
 
-        var points = 0;
+        let points = 0;
 
-        for (pref = 0; pref < prefixList.length; pref++) {
-          var prefix = " " + prefixList[pref];
+        prefixList.forEach(function(p) {
 
           // Check if it matches at the beginning
-          // if ((this.item(pos).lcField().indexOf(prefix)) >= 0) {
-          if ((this.item(pos).lcField().includes(prefix))) {
+          if ((it.lcField().includes(" " + p))) {
             points += 5;
           }
 
           // Check if it matches anywhere
-          // else if ((this.item(pos).lcField().indexOf(prefix.substring(1))) >= 0) {
-          else if ((this.item(pos).lcField().includes(prefix.substring(1)))) {
+          else if (it.lcField().includes(p)) {
             points += 1;
           };
-        };
+        });
 
         if (points > maxPoints) {
           this._list = [pos];
@@ -255,7 +252,7 @@
         else if (points == maxPoints) {
           this._list.push(pos);
         }
-      };
+      },this);
 
       // The list is empty - so lower your expectations
       // Iterate over all items and choose matching items
diff --git a/dev/js/src/menu/item.js b/dev/js/src/menu/item.js
index e06de1e..f0c531f 100644
--- a/dev/js/src/menu/item.js
+++ b/dev/js/src/menu/item.js
@@ -194,21 +194,22 @@
         var len = 0;
 
         // Iterate over all prefixes and get the best one
-        for (var i = 0; i < prefixes.length; i++) {
+        // for (var i = 0; i < prefixes.length; i++) {
+        prefixes.forEach(function(i) {
 
           // Get first pos of a matching prefix
-          testPos = textlc.indexOf(prefixes[i]);
+          testPos = textlc.indexOf(i);
           if (testPos < 0)
-            continue;
+            return;
 
           if (pos === -1 || testPos < pos) {
             pos = testPos;
-            len = prefixes[i].length;
+            len = i.length;
           }
-          else if (testPos === pos && prefixes[i].length > len) {
-            len = prefixes[i].length;
+          else if (testPos === pos && i.length > len) {
+            len = i.length;
           };
-        };
+        });
 
         // Matches!
         if (pos >= 0) {
diff --git a/dev/js/src/panel/match.js b/dev/js/src/panel/match.js
index a6c50db..99f7366 100644
--- a/dev/js/src/panel/match.js
+++ b/dev/js/src/panel/match.js
@@ -164,17 +164,15 @@
       var menuList = [];
       
       // Show tree views
-      for (var i = 0; i < treeLayers.length; i++) {
-        var span = treeLayers[i];
-        
-        // Add foundry/layer to menu list
-        menuList.push([
-          span.foundry + '/' + span.layer,
-          span.foundry,
-          span.layer,
-          span.type
-        ]);
-      };
+      treeLayers.forEach(
+        s => 
+          // Add foundry/layer to menu list
+          menuList.push([
+            s.foundry + '/' + s.layer,
+            s.foundry,
+            s.layer,
+            s.type
+          ]));
 
       // Create tree menu
       this._menuList = menuList;
diff --git a/dev/js/src/selectMenu.js b/dev/js/src/selectMenu.js
index 4db1dcd..dc2c8e6 100644
--- a/dev/js/src/selectMenu.js
+++ b/dev/js/src/selectMenu.js
@@ -12,13 +12,13 @@
 
 	      // Prepare list before object upgras
 	      var list = [];
-	      var options = select.getElementsByTagName('option');
 
         // Iterate through options list
-	      for (var i = 0; i < options.length; i++) {
-
+        Array.from(
+          select.getElementsByTagName('option')
           // Get option item and add to list
-	        var item = options.item(i);
+        ).forEach(function(item) {
+        
 	        var opt = [
 	          item.textContent,
 	          item.getAttribute('value')
@@ -29,7 +29,7 @@
 	          opt.push(item.getAttribute('desc'));
 
 	        list.push(opt);
-	      };
+	      });
 
 	      // Create object with list
 	      var obj = Object.create(menuClass).upgradeTo(this)
diff --git a/dev/js/src/session.js b/dev/js/src/session.js
index 2211fe6..178b83c 100644
--- a/dev/js/src/session.js
+++ b/dev/js/src/session.js
@@ -54,16 +54,17 @@
   /* Parse cookie */
   _parse : function () {
     var c = document.cookie;
-    var part = document.cookie.split(';');
-    for(var i = 0; i < part.length; i++) {
-      var pair = part[i].split('=');
-      var name = pair[0].trim().toLowerCase();
-      if (name === this._name) {
-	      if (pair.length === 1 || pair[1].length === 0)
+    document.cookie.split(';').forEach(
+      function(i) {
+        var pair = i.split('=');
+        var name = pair[0].trim().toLowerCase();
+        if (name === this._name) {
+	        if (pair.length === 1 || pair[1].length === 0)
+	          return;
+          this._hash = JSON.parse(decodeURIComponent(pair[1]));
 	        return;
-        this._hash = JSON.parse(decodeURIComponent(pair[1]));
-	      return;
-      };
-    };
+        };
+      }
+    );
   }
 });
diff --git a/dev/js/src/tutorial.js b/dev/js/src/tutorial.js
index 2420707..c2f7c69 100644
--- a/dev/js/src/tutorial.js
+++ b/dev/js/src/tutorial.js
@@ -95,27 +95,27 @@
      * Decorate a page with query event handler.
      */
     initQueries : function (d) {
-      var qs = d.querySelectorAll('pre.query.tutorial:not(.unsupported)');
-      var that = this;
-      for (var i = 0; i < qs.length; i++) {
-	      qs[i].onclick = function (e) {
-	        that.useQuery(this,e);
-	      };
-      };
+      let that = this;
+      Array.from(d.querySelectorAll('pre.query.tutorial:not(.unsupported)')).forEach(
+        i =>
+	        i.onclick = function (e) {
+	          that.useQuery(this,e);
+	        }
+      );
     },
 
     /**
      * Decorate a page with documentation links
      */
     initDocLinks : function (d) {
-      var dl = d.getElementsByClassName('doc-link');
-      var that = this;
-      for (var i = 0; i < dl.length; i++) {
-	      dl[i].onclick = function (e) {
-	        that.setPage(this.getAttribute('href'));
-	        return true;
-	      };
-      };      
+      let that = this;
+      Array.from(d.getElementsByClassName('doc-link')).forEach(
+	      i =>
+          i.onclick = function (e) {
+	          that.setPage(this.getAttribute('href'));
+	          return true;
+	        }
+      );    
     },
 
 
diff --git a/dev/js/src/vc/docgroup.js b/dev/js/src/vc/docgroup.js
index af49191..47f3a96 100644
--- a/dev/js/src/vc/docgroup.js
+++ b/dev/js/src/vc/docgroup.js
@@ -30,13 +30,13 @@
     },
     
     newAfter : function (obj) {
-      for (var i = 0; i < this._operands.length; i++) {
-	      if (this._operands[i] === obj) {
+      this._operands.forEach(function (op, i) {
+	      if (op === obj) {
 	        var operand = unspecClass.create(this);
 	        this._operands.splice(i + 1, 0, operand);
 	        return this.update();
 	      };
-      };
+      }, this);
     },
 
     // The doc is already set in the group
@@ -48,15 +48,17 @@
       if (operand.ldType() !== 'doc')
 	      return null;
 
-      for (var i = 0; i < this._operands.length; i++) {
-	      var op = this.getOperand(i);
-	      if (op.ldType() === 'doc'
-	          && operand.key() === op.key()
-	          && operand.matchop() === op.matchop()
-	          && operand.value() === op.value()) {
-	        return op;
-	      };
-      };
+      const f = this._operands.find(
+        op => 
+	        op.ldType() === 'doc'
+	        && operand.key() === op.key()
+	        && operand.matchop() === op.matchop()
+	        && operand.value() === op.value()
+      );
+
+      if (f)
+        return f;
+
       return null;
     },
     
@@ -194,11 +196,9 @@
       _removeChildren(group);
 
       // Append operands
-      for (var i = 0; i < this._operands.length; i++) {
-	      group.appendChild(
-	        this.getOperand(i).element()
-	      );
-      };
+      this._operands.forEach(
+        op => group.appendChild(op.element())
+      );
 
       // Set operators
       var op = this.operators(
@@ -342,10 +342,10 @@
 
     toJson : function () {
       var opArray = new Array();
-      for (var i = 0; i < this._operands.length; i++) {
-	      if (this._operands[i].ldType() !== 'non')
-	        opArray.push(this._operands[i].toJson());
-      };
+      this._operands.forEach(function(op) {
+	      if (op.ldType() !== 'non')
+	        opArray.push(op.toJson());
+      });
       return {
 	      "@type"     : "koral:" + this.ldType(),
 	      "operation" : "operation:" + this.operation(),
diff --git a/dev/js/src/vc/jsonld.js b/dev/js/src/vc/jsonld.js
index 21260d4..cfa0acc 100644
--- a/dev/js/src/vc/jsonld.js
+++ b/dev/js/src/vc/jsonld.js
@@ -52,8 +52,7 @@
       
       // In case of a group, destroy all operands
       if (this._operands !== undefined) {
-	      for (var i = 0; i < this._operands.length; i++)
-	        this.getOperand(i).destroy();
+        this._operands.forEach(i => i.destroy());
 	      this._operands = [];
       };
     },
diff --git a/dev/js/src/vc/rewritelist.js b/dev/js/src/vc/rewritelist.js
index 75f3d27..d6885c9 100644
--- a/dev/js/src/vc/rewritelist.js
+++ b/dev/js/src/vc/rewritelist.js
@@ -15,11 +15,12 @@
      */
     fromJson : function (json) {
       this._list = new Array();
-      for (var i = 0; i < json.length; i++) {
-	      this._list.push(
-	        rewriteClass.create(json[i])
-	      );
-      };
+      json.forEach(
+        i => 
+	        this._list.push(
+	          rewriteClass.create(i)
+	        )
+      );
       return this;
     },
 
diff --git a/dev/js/src/vc/statistic.js b/dev/js/src/vc/statistic.js
index cd8d0ce..0c3c6ca 100644
--- a/dev/js/src/vc/statistic.js
+++ b/dev/js/src/vc/statistic.js
@@ -44,16 +44,14 @@
       statDL.classList.add("flex");
       var statistic = this._statistic;
 
-      var keys = Object.keys(statistic);
-      for (i = 0; i < keys.length; i++) {
+      Object.keys(statistic).forEach(function(k) {
         statSp = statDL.addE('div')
         statDT = statSp.addE('dt');
-        var k = keys[i];
         statDT.addT(k);
         statDT.setAttribute('title', k);
         statDD = statSp.addE('dd');
         statDD.addT(new Number(statistic[k]).toLocaleString());
-      }
+      });
 
       this._element = statDL;
       return this._element;
diff --git a/dev/js/src/view/match/tokentable.js b/dev/js/src/view/match/tokentable.js
index 2ac361d..e954068 100644
--- a/dev/js/src/view/match/tokentable.js
+++ b/dev/js/src/view/match/tokentable.js
@@ -84,8 +84,7 @@
       else {
         
         // Push newly to focus array
-        for (var i = 0; i < tokens.length; i++) {
-          var term = tokens[i];
+        tokens.forEach(function(term) {
           try {
             // Create info layer objects
             var layer = infoLayerClass.create(term);
@@ -93,9 +92,9 @@
             focus.push(layer);
           }
           catch (e) {
-            continue;
+            return;
           };
-        };
+        });
       };
       
       // No tokens chosen
