所以我一个数组,它包含两种不同的阵列:过滤器一个数组,它是另一个数组
var _staticRoutingTable = [];
function StaticRoute(directory, extentions) {
this.dir = directory;
this.extentions = extentions;
}
_staticRoutingTable.push(new StaticRoute(["htmlfolder"], ["./html"]));
_staticRoutingTable.push(new StaticRoute(["somefolder"], ["./html","./txt","./css"]));
可以说,我只希望获得“目录” Array中的文件夹的名称是“somefolder” 。
所以我不想水木清华这样的,因为...:
return _staticRoutingTable.forEach(function callb(route) {
return route.dir.filter(function callb(directory) {directory=="somefolder" })
});
....我得到DIR + extention阵列。我怎样才能过滤一个数组(在这种情况下“dir”)。
所以你想在完整的StaticRoute,其中this.dir =='somefolder'? – baao
@baao不,我不想完整的StaticRoute,我只想返回一个数组,其中包含一个名为“somefolder”的字符串(在本例中为9 – igodie