First is faster, but remember that this 2 methods are totaly different!
Let’s assume that your table contains only numbers and strings (not tables, functions etc)
First one:
create ‘table’ and reserve place in memory for it - let’s call this address 0x11111
create variable ‘tmpTable’
assign to ‘tmpTable’ address 0x1111 in memory pointing to ‘table’ (adress, because tables are passed by reference, not as a copy)
What you have here is called ‘shallow-copy’
[lua]
local table = {}
local tmpTable
tmpTable = table
–if you now do
table.prop= 2
–then tmpTable will also have property ‘prop’
print(tmpTable.prop) – this will give you ‘2’ in terminal because both variables are referencing to the same object
[/lua]
In the second one when you copy it this way, only table.prop will be ‘2’ an there will be no ‘prop’ property in tmpTable
It’s called “deep-copy” because you are copying by values and numbers and strings are not passed by it’s address in memory but only it’s value