Simple JavaScript HTML table generator This is my simple implementation on JS HTML table generator which generates a table based on an array of JS objects.

function Column(caption,position,isVisible,values){
  this.caption = caption;
  this.position = position;
  this.isVisible = isVisible;
  this.values = values;
}


Column.prototype.printValue = function (index){
      return  "&lt;td&gt;"+ this.values[index] +"&lt;/td&gt;";
};


var columnArray = [                    
                    new Column("Id",0,true,[1,2,3]),
                    new Column("Name",1,true,["Tim","Jim","Tom"]),
                    new Column("Date",2,true,["27-03-2014","01-01-2014","11-04-2015"])
                  ];

function columnSorter(columnA,columnB){
  if(columnA.position &lt; columnB.position)
    return -1;
  if(columnA.position &gt; columnB.position)
    return 1;
  return 0;
}


columnArray.sort(columnSorter);


function generateTable(columnArray){
  var htmlString = "&lt;table&gt;&lt;thead&gt;&lt;tr&gt;";

  for(var col in columnArray){
    htmlString += "&lt;th&gt;"+columnArray[col].caption+"&lt;/th&gt;";
  }

  htmlString += "&lt;tfoot&gt;&lt;/tfoot&gt;";

  htmlString += "&lt;tbody&gt;";
  for(var i=0;i&lt;columnArray[0].values.length;i++){
    htmlString += "&lt;tr&gt;";
    for(col in columnArray){
      htmlString += columnArray[col].printValue(i);
    }
    htmlString += "&lt;/tr&gt;";
  }
  htmlString +="&lt;/tbody&gt;";

  htmlString += "&lt;/tr&gt;&lt;/thead&gt;";
  return htmlString += "&lt;/table&gt;";
}
Since position is a number, you can simplify your columnSorter function. It becomes a one-liner, so you could even do:

columnArray.sort(function(a, b) { return a.position - b.position; });


Note though that some people consider this less readable. It's definitely less explicit in what it does, so you may wish to explain it in a comment.
You're using a for..in construct. This will give unexpected results if I extend Array.prototype. Either use a regular for loop, or check for columnArray.hasOwnProperty(col) in each iteration.
Why add an empty &lt;tfoot&gt;?
You're closing your &lt;thead&gt; in the wrong spot. &lt;tbody&gt; and &lt;tfoot&gt; should be children of &lt;table&gt;, not children of &lt;thead&gt;, so close your &lt;thead&gt; earlier.
It doesn't make much sense to return x += y;. Either return x + y;, or do x += y; return x;.