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?
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
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
typeof extends type meaning if UserData is found Roblox will try ang get its internal type then fall back to UserData.
They're the same CallBack methods, ROBLOX is going to deprecate type() soon to replace typeof(), though nothing changed about their functionality.