简体   繁体   English

Node.js:_.chain下划线中的异步回调

[英]Node.js: Async callback in _.chain underscore

The arr.length is still undefined after I call _.chain() underscore operation: 我调用_.chain()下划线操作后, arr.length仍未定义:

var arr = _.chain(msg)
   .groupBy(function(item) {return item.ts_simple; })
   .value();

console.log(arr.length); //undefined
console.log(arr); //correct object array

The first console.log(arr.length) for underscore var array length is undefined while the console.log(arr) outputs the correct returned object array. 所述第一console.log(arr.length)为下划线var阵列长度是undefined ,而console.log(arr)输出正确的返回的对象阵列。

How do I callback after underscore operation is complete? 下划线操作完成后如何回调?

groupBy() returns an object, not an array. groupBy() 返回一个对象,而不是数组。

It has no length property. 它没有length属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM