TypeScript For In Loop Control

The for..in statement iterates over the enumerable properties of an object,in arbitrary order. For each distinct property, statements can be executed. In each iteration one property from object is assigned to variable and this loop continues till the end of the object.


for (variable in object) 
  block to execute 

TypeScript For In Loop Example 1

  var val:string;
   var obj = {a:1, b:2, c:3}; 
   for (var prop in obj) {
	  this.val += prop + " = " + obj[prop] + "\n";
  return this.val;		
Try it Yourself