I'm getting this weird error.
Uncaught SyntaxError: Unexpected token [
I don't know why this error occurs.
Could anyone please tell me why this error occurs and how to solve it?
sortedArray.push({filteredKeys[i]:_analyzedDataSet[filteredKeys[i]]});
This error occurs on this line above.
console.log("filteredKeys[i]:%s", filteredKeys[i]);
However, this line above works fine.
console.log("_analyzedDataSet[filteredKeys[i]]:%s", _analyzedDataSet[filteredKeys[i]]);
Also, this line above works fine.
var filteredKeys = [];
filteredKeys = sortThis(_analyzedDataSet);
var sortedArray = [];
for (var i = 0; i < filteredKeys.length; i++){
//This doesn't cause an error.
console.log("filteredKeys[i]:%s", filteredKeys[i]);
//This doesn't cause an error as well.
console.log("_analyzedDataSet[filteredKeys[i]]:%s", _analyzedDataSet[filteredKeys[i]]);
//But, this cause an error!!
sortedArray.push({filteredKeys[i]:_analyzedDataSet[filteredKeys[i]]});
}