I am experiencing some very odd behavior with underscore.js _.map
function.
It seems as though when I try to "new up" an object inside the function, it fails. But without a new object inside the function, it works as expected. Am I missing something here?
The following does not work (i.e. it prints nothing). It seems to be failing after the new object is created:
var test = { a: "test" };
var foo = _.map(data.A, function (dataItem) {
var a = new test();
console.log(a);
return a;
});
But this does work:
var test = { a: "test" };
var foo = _.map(data.A, function (dataItem) {
var a = dataItem;
console.log(a);
return a;
});
And the above logs all of the items in the data.A array.