Run the following module from the console (= p.test()):
local p = {} function p.test() local entity, statements entity = mw.wikibase.getEntity('Q213') statements = entity:getAllStatements('P1082') mw.log(#statements) table.remove(statements) mw.log(#statements, #entity:getAllStatements('P1082'), #entity.claims.P1082) entity = mw.wikibase.getEntity('Q213') statements = entity:getBestStatements('P1082') mw.log(#statements) table.remove(statements) mw.log(#statements, #entity:getBestStatements('P1082'), #entity.claims.P1082) end return p
(table.remove performs in-place removal of the last element in the sequence.)
You will get:
35 34 34 34 1 0 1 35
In other words, changing the value returned from getAllStatements will change it for all following calls and also change the entity object.
This does not happen with getBestStatements.