You need to cache this
. Once you enter the setTimeout
's anonymous function, this
now refers to the scope of the function that you just declared.
if(tempArray.length <= 0){
var self = this; // Cache the current scope's `this`
setTimeout(function(){
self.storage.set(achkey,1);
},2000);
}