In the Chrome console, I executed the following function:
function getData_working(){
return [
{Category: "Category 1", Key: "Key 10", Value: 1},
{Category: "Category 2", Key: "Key 10", Value: 1}
];
}
It does work and executing getData_working()
afterwards produces the expected array with two objects. However, when I execute the following function (and I've actually copied the former, only changing the placement of the brackets, to make sure it isn't a typo), I get undefined
.
function getData2_failing(){
return
[{Category: "Category 1", Key: "Key 10", Value: 1},
{Category: "Category 2", Key: "Key 10", Value: 1}];
}
What's happening here? How does someone explain this "bug" or "feature"?