Javascript Callback function scope issue -
i having trouble in
how assign value in callback function?
thanks rodik have general idea of how it. however, still not sure how pass img
value getimage
function
...
project.prototype.getimagepath = function(){ codes... this.getfolder(path); //how img value inside getimage function? } project.prototype.getfolder = function(path){ this.imagepath; var instance = this; var images = ['http://project/path.png', 'http://project2/path.png']; function getimage(images, callback) { var iterator = function (i) { if (i < images.length) { var image = newimage(); //..codes check if image path valid //if valid, pass image callback(image); } iterator(++i); } } iterator(0); } getimage(images, function (img) { console.log(img) //output img instance.imagepath = img }); }
thanks guys~~
Comments
Post a Comment