object.property vs property

Hello, programmers. In JavaScript such a code:
object.property
works slower than such a code:
property
Is the situation the same in Unity JavaScript?

Excuse me for my English, it’s not my native language. If you can, please, correct the post :slight_smile:

Thanks.

Yes, it is slower to do a dereference using ‘.’ It isn’t quite as bad as real Javascript, because UnityScript already knows a lot more about the structure of the object, but you want to be caching copies of things that you use often, especially in Update() functions. That does also include some of the properties on the GameObject that you access without a ‘.’ like transform, caching them is a good idea.

Big thanks! All clear!