For (var I=0; i <6; I++) {
Session. PingHost (the list [I] server, (error, target, sent, RCVD)=& gt; {
If (error) {
The console. The log (` failed `);
} else {
Const spent=RCVD. GetTime () - sent. GetTime ();
A (target, spent);
}
})
Var newArr=[];
Function a (IP, data) {
The console. The log (" a: "+ I);
//var newArr=[];
NewArr. Push ({
"IP" : IP,
"ResT" : data
});
The console. The log (newArr)
}
The function () {b
The console. The log (" b: "+ I);
}
(b)
}
Everyone here are two questions to ask:
1. The above For loop, why a (IP, data) {the console. The log (" a: "+ I)} output value has always been a 6, and b () {the console. The log (" b:" + I); } of the output value is 0 b,1,2,3,4,5??
2. Var newArr=[]; Function a (IP, data) {the console. The log (" a: "+ I); NewArr. Push ({" IP ": IP," ResT ": data}); The console. The console in the log (newArr)}. The log (newArr) of the output value below
I just want to output the data in the red box above, other don't output , could you tell me how to write?
CodePudding user response:
Sorry, I know what reason theCodePudding user response: