for key in pairs(t) do
t[key] = nil
end
would clear any table entirely. I think you might be confusing it with
for key in ipairs(t) do
t[key] = nil
end
this would clear the table of keys 1 till n where n is the first key for which t[n+1] == nil.
Example:
t = {
[1] = 2,
[2] = 3,
[4] = 2,
a = 1
}
First method would clear it, second method would leave keys 4 and a in it