The title pretty much sums it up. What is the difference between the two?
The first difference between the pairs() and ipairs() function is that the pairs() function doesn't maintain the key order whereas the ipairs() function do. Also ipairs() are way faster than pairs()
ipairs is equivalent to a numerical loop, making it faster when iterating over large ordered arrays. pairs are used to iterate over tables that aren't arrays or are unordered
More info on these webs Devforum
Hope this helps!!
Here is an easy way to visualize it.
local table = {[5] = 5, [3] = 3, [4] = 4, [1] = 1, [2] = 2} for i,v in pairs(table) do print(v) end --The above statement would print out 5,3,4,1,2 for i,v in ipairs(table) do print(v) end -- this would print 1,2,3,4,5 as it is doing it in order of the numerical indexes.