Is it better to clear a table or set it to nil?

I have a table in a script, after one use, I do not plan on using it again, so which way is better when it comes to efficiency?
Should I clear the table like this?
for index in pairs(thisTable) do thisTable[index] = nil end
Or should I just set the table to nil like this?
thisTable = nil

Way simpler to just do Table = nil, I’m assuming that Table = nil uses less memory than a loop but its a minute difference. Whatever floats your boat.

2 Likes

It’s simpler to just do table.clear(thisTable) in my opinion. Keep the table and it clears it without a loop.

Just set it to nil since you are not gonna use it anymore.

The documentation says :

As you can see here its really situational. When you need to re-use the space in table this method is better.