local t1 = {ss = 1, dd = 2}
local t2 = {"a", "b", "c"}
function isArrayT(t)
if type(t) ~= "table" then
return false
end
local n = #t
for i,v in pairs(t) do
if type(i) ~= "number" then
return false
end
if i > n then
return false
end
end
return true
end
print(isArrayTable(t1))
print(isArrayTable(t2))
输出:
false
true