我有一个包含多个数组的数组,每个数组中包含多个对象,类似于这样。
[[object1, object2],[object1],[object1,object2,object3]]
这里是被记录到控制台的对象的截图。
将其展平为一个对象数组的最佳方法是什么?
我已经尝试过,但没有成功:
console.log(searchData);
var m = [].concat.apply([],searchData);
console.log(m);
searchData记录了上面截图中的注销信息,但是m没有记录。
下面是searchData的实际内容:
[[{"_id":"55064111d06b96d974937a6f","title":"Generic Title","shortname":"generic-title","contents":"<p>The Healing Center offers practical, social, and spiritual support to individuals and families. Services include, but are not limited to: food and clothing, job skills training and job search assistance, auto repair (Saturdays only), mentoring, financial counseling, tutoring, prayer, life skills training, and helpful information about local community services.</p><p>Stay in touch with us:</p>","__v":0},{"_id":"5508e1405c621d4aad2d2969","title":"test english","shortname":"test-page","contents":"<h2>English Test</h2>","__v":0}],[{"_id":"550b336f33a326aaee84f883","shortname":"ok-url","title":"now english","contents":"<p>okokko</p>","category":"Transportation","__v":0}]]
arr.reduce(function(a,b){return a.concat(b);});
这行代码。 - dandavis