dimanche 1 mars 2015

How do I invoke a function within a for loop?

How can I call future.wait within a for loop function?


As of now, the returned 'singleObject' is coming out as undefined.


What I am trying to achieve is as follows.



  1. create my object from each iteration


2.Pass this object into another function and process further. Do I 'return' the next function. I am confused as to how to invoke functions within a function in this for loop



function createObjectFromArray(array) { //data is an array with multiple object
var len = array.length
for (var i=0; i<len; i++) {
var singleObject = {
fieldOne: array[i].someField.valueOne,
fieldTwo: array[i].someField.valueTwo
}
} //end of for loop
myNextFUnction(singleObject)
}

Aucun commentaire:

Enregistrer un commentaire