I am trying to give an object a countdown timer and when the countdown is down it should call a function which removes this object from an array.
array = [];
var object = {
'name' : 'user',
'limit' : function() {
setTimeout(destroyMe(this),10000);
}
}
array.push(object);
var destroyMe = function(obj) {
array.remove(obj);
}
I know that there could a problem with the this but the timeout function doesnt work at all not even like this:
var object = {
'name' : 'user',
'limit' : function() {
setTimeout(console.log("dd"),3000);
}
}
Maybe someone can tell me the issue with my version of the setTimeout. thx