嗨我有一个数组,其中包含以下数字,但是当我通过eachNode函数(迭代13次)循环时,它将重复所有列表元素13次。我测试了一切,但它仍然产生一个错误,我正在执行for循环?Javascript索引数组问题
list[61,67,78]
var len = list.length;
fd.graph.eachNode(function (node) { // loops thru all node id's in graph (13)
for (var i = 0; i < len; ++i) {
if (i in list) {
var nody = list[i]; // I put the number in a variable
var nodess = fd.graph.getNode(nody); //this takes the number and matches it with a node id, it "odjectify" it
if (node.id != nodess.id) { // if the list nodes are not the same
node.setData('alpha', 0); //
node.eachAdjacency(function (adj) { // this make the unmatched nodes disappear
adj.setData('alpha', 0, 'end');
});
}
}
}
});
你想用'if(我在列表中)'做什么? – 0x499602D2 2013-04-20 23:39:32
这是微不足道的,我用于索引 – Squirtle 2013-04-20 23:40:32