Your question is in fact about the object properties square bracket notation :
using object[propertyname] is the same as using object.propertyname.
var myObj = {};
myObj['x'] = 12;
console.log(myObj.x); -->> prints 12
Now in your code :
var arrayOfObjects = [];
for(var i=0; i<values.length; i++){
var obj = {};
for(var j=0; j<values[i].length; j++){
obj[keys[j]] = values[i][j];
}
arrayOfObjects.push(obj);
}
In reply to 'it does weird things' : this code works.
with this input :
var keys = ['key1', 'key2', 'key3'];
var values = [
[12,112, 1112],
[31, 331, 3331],
[64, 65, 66]
];
the output is :
{ {key1: 12, key2: 112, key3: 1112},
{key1: 31, key2: 331, key3: 3331},
{key1: 64, key2: 65, key3: 66} }
fiddle is here :
http://jsfiddle.net/fyt8A/