78
rated 0 times
[
82]
[
4]
/ answers: 1 / hits: 38436
/ 11 Years ago, tue, july 2, 2013, 12:00:00
var cache = [];
cache[0] = 0;
cache[1] = 1;
cache[2] = 2;
cache[3] = 3;
cache[4] = 4;
cache[r] = r;
console.log(cache.length);
for(key in cache){
if(isNaN(key))continue;
else cache.splice(key,1); // cache.splice(key) is working fine, ***
}
console.log(cache);
Question : in line ***
Why splice(key) is working fine (Deleting All Elements with Numeric Index) and splice(key,1) not working fine (Not Deleting Elements with Numeric index). Even i have tried
splice(key,1) // Not working as splice(key)
splice(key--,1) // Even not working as splice(key)
splice(key,0) // not deleting any thing
You can copy and paste code in Firebug console for testing.
More From » jquery