我有以下代码:
var dataArray = [];
switch (request_url.query.group) {
case 'returning':
dataArray = {};
var returning = _.filter(result, function(result) {
return (result.sessions.length > 1) ? true : false;
});
//Am I setting the object dataArray here?
dataArray.returning = returning.length;
//Am I setting the array dataArray here?
dataArray['new'] = result.length - returning.length;
break;
我在这里对 dataArray 感到困惑。第一行代码声明了一个数组,并且在 switch case 中声明了一个同名对象。什么是“新”和“返回”值集,它们分别属于谁,数组还是对象?另外,对象是 Node.js 中数组的超类吗?