Index: binaries/data/mods/public/simulation/components/GarrisonHolder.js
===================================================================
--- binaries/data/mods/public/simulation/components/GarrisonHolder.js	(revision 18516)
+++ binaries/data/mods/public/simulation/components/GarrisonHolder.js	(working copy)
@@ -66,13 +66,13 @@
 	this.visibleGarrisonPoints = [];
 	if (this.template.VisibleGarrisonPoints)
 	{
-		for each (var offset in this.template.VisibleGarrisonPoints)
+		for (let offset in this.template.VisibleGarrisonPoints)
 		{
-			var o = {};
+			let o = {};
 			o.x = +offset.X;
 			o.y = +offset.Y;
 			o.z = +offset.Z;
-			this.visibleGarrisonPoints.push({"offset":o, "entity": null});
+			this.visibleGarrisonPoints.push({ "offset": o, "entity": null }); 
 		}
 	}
 };
@@ -163,11 +163,10 @@
  */
 GarrisonHolder.prototype.IsGarrisoningAllowed = function()
 {
-	for each (var allow in this.allowGarrisoning)
-	{
+	for (let allow in this.allowGarrisoning)
 		if (!allow)
 			return false;
-	}
+
 	return true;
 };
 
@@ -177,10 +176,10 @@
 GarrisonHolder.prototype.GetGarrisonedEntitiesCount = function()
 {
 	var count = 0;
-	for each (var ent in this.entities)
+	for (let ent of this.entities)
 	{
-		count++;
-		var cmpGarrisonHolder = Engine.QueryInterface(ent, IID_GarrisonHolder);
+		++count;
+		let cmpGarrisonHolder = Engine.QueryInterface(ent, IID_GarrisonHolder);
 		if (cmpGarrisonHolder)
 			count += cmpGarrisonHolder.GetGarrisonedEntitiesCount();
 	}
@@ -305,10 +304,9 @@
 	var cmpIdentity = Engine.QueryInterface(this.entity, IID_Identity);
 	// If the garrisonHolder is a sinking ship, restrict the location to the intersection of both passabilities
 	// TODO: should use passability classes to be more generic
-	if ((!cmpHealth || cmpHealth.GetHitpoints() == 0) && cmpIdentity && cmpIdentity.HasClass("Ship"))
-		var pos = cmpFootprint.PickSpawnPointBothPass(entity);
-	else
-		var pos = cmpFootprint.PickSpawnPoint(entity);
+	var pos = (!cmpHealth || cmpHealth.GetHitpoints() === 0) && cmpIdentity && cmpIdentity.HasClass("Ship") ?
+		cmpFootprint.PickSpawnPointBothPass(entity) :
+		cmpFootprint.PickSpawnPoint(entity);
 
 	if (pos.y < 0)
 	{
@@ -332,7 +330,7 @@
 		if (vgp.entity != entity)
 			continue;
 		cmpNewPosition.SetTurretParent(INVALID_ENTITY, new Vector3D());
-		var cmpUnitAI = Engine.QueryInterface(entity, IID_UnitAI);
+		let cmpUnitAI = Engine.QueryInterface(entity, IID_UnitAI);
 		if (cmpUnitAI)
 			cmpUnitAI.ResetTurretStance();
 		vgp.entity = null;
@@ -377,9 +375,9 @@
 			// ignore the rally point if it is autogarrison
 			if (commands[0].type == "garrison" && commands[0].target == this.entity)
 				return;
-			for each (var com in commands)
+			for (let command of commands)
 			{
-				ProcessCommand(cmpOwnership.GetOwner(), com);
+				ProcessCommand(cmpOwnership.GetOwner(), command);
 			}
 		}
 	}
@@ -403,8 +401,8 @@
 	{
 		if (failedRadius !== undefined)
 		{
-			var cmpObstruction = Engine.QueryInterface(entity, IID_Obstruction);
-			var radius = cmpObstruction ? cmpObstruction.GetUnitRadius() : 0;
+			let cmpObstruction = Engine.QueryInterface(entity, IID_Obstruction);
+			let radius = cmpObstruction ? cmpObstruction.GetUnitRadius() : 0;
 			if (radius >= failedRadius)
 				continue;
 		}
@@ -411,8 +409,8 @@
 
 		if (this.Eject(entity, forced))
 		{
-			var cmpOwnership = Engine.QueryInterface(this.entity, IID_Ownership);
-			var cmpEntOwnership = Engine.QueryInterface(entity, IID_Ownership);
+			let cmpOwnership = Engine.QueryInterface(this.entity, IID_Ownership);
+			let cmpEntOwnership = Engine.QueryInterface(entity, IID_Ownership);
 			if (cmpOwnership && cmpEntOwnership && cmpOwnership.GetOwner() == cmpEntOwnership.GetOwner())
 				ejectedEntities.push(entity);
 		}
@@ -423,7 +421,7 @@
 				failedRadius = Math.min(failedRadius, radius);
 			else
 			{
-				var cmpObstruction = Engine.QueryInterface(entity, IID_Obstruction);
+				let cmpObstruction = Engine.QueryInterface(entity, IID_Obstruction);
 				failedRadius = cmpObstruction ? cmpObstruction.GetUnitRadius() : 0;
 			}
 		}
@@ -463,13 +461,12 @@
 
 	var entities = [];
 	var cmpTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager);
-	for each (var entity in this.entities)
+	for (let entity of this.entities)
 	{
 		var cmpIdentity = Engine.QueryInterface(entity, IID_Identity);
 
 		// Units with multiple ranks are grouped together.
-		var name = cmpIdentity.GetSelectionGroupName()
-		           || cmpTemplateManager.GetCurrentTemplateName(entity);
+		var name = cmpIdentity.GetSelectionGroupName() || cmpTemplateManager.GetCurrentTemplateName(entity);
 
 		if (name != template)
 			continue;
@@ -541,15 +538,15 @@
  */
 GarrisonHolder.prototype.HealTimeout = function(data)
 {
-	if (this.entities.length == 0)
+	var cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer);
+	if (this.entities.length)
 	{
-		var cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer);
 		cmpTimer.CancelTimer(this.timer);
 		this.timer = undefined;
 	}
 	else
 	{
-		for each (var entity in this.entities)
+		for (let entity of this.entities)
 		{
 			var cmpHealth = Engine.QueryInterface(entity, IID_Health);
 			if (cmpHealth)
@@ -559,7 +556,7 @@
 					cmpHealth.Increase(this.GetHealRate());
 			}
 		}
-		var cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer);
+		cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer);
 		this.timer = cmpTimer.SetTimeout(this.entity, IID_GarrisonHolder, "HealTimeout", 1000, {});
 	}
 };
@@ -596,7 +593,7 @@
 	if (this.entity == msg.entity)
 	{
 		var entities = [];
-		for each (var entity in this.entities)
+		for (let entity of this.entities)
 		{
 			if (msg.to == -1 || !IsOwnedByMutualAllyOfEntity(this.entity, entity))
 				entities.push(entity);
@@ -612,7 +609,7 @@
 	{
 		// If the entity is dead, remove it directly instead of ejecting the corpse
 		var cmpHealth = Engine.QueryInterface(msg.entity, IID_Health);
-		if (cmpHealth && cmpHealth.GetHitpoints() == 0)
+		if (cmpHealth && cmpHealth.GetHitpoints() === 0)
 		{
 			this.entities.splice(entityIndex, 1);
 			Engine.PostMessage(this.entity, MT_GarrisonedUnitsChanged, { "added" : [], "removed": [msg.entity] });
@@ -694,7 +691,7 @@
 
 	// And destroy all remaining entities
 	var killedEntities = [];
-	for each (var entity in entities)
+	for (let entity of entities)
 	{
 		var entityIndex = this.entities.indexOf(entity);
 		if (entityIndex == -1)
@@ -719,10 +716,8 @@
 	var ejectableClasses = this.template.EjectClassesOnDestroy._string;
 	ejectableClasses = ejectableClasses ? ejectableClasses.split(/\s+/) : [];
 	var entityClasses = (Engine.QueryInterface(entity, IID_Identity)).GetClassesList();
-	for each (var ejectableClass in ejectableClasses)
-		if (entityClasses.indexOf(ejectableClass) != -1)
-			return true;
-
+	if (ejectableClasses.some(ejectableClass => entityClasses.indexOf(ejectableClass) != -1))
+		return true;
 	return false;
 };