The wiki doesn't really go much into in-depth with the difference, all it says is that 'typeof' is more useful but how?
What is the difference aren't they the same thing?
Both type
and typeof
return what sort of data a variable is referring to. An excellent demonstration is given here: https://www.lua.org/pil/2.html
A frustration one might have in Roblox (before typeof
came along) was that you couldn't tell the difference between Vector2, Vector3, Instance, etc - type
just said they were all userdata
. typeof
fixes that problem.
ex:
print(type(workspace)) -- userdata print(typeof(workspace)) -- Instance print(type(Vector3.new())) -- userdata print(typeof(Vector3.new())) -- Vector3