Can you use Unit JS script like standard JS DOM?

Is it possible to use the JS in a DOM like fashion. That is being able to navigate around all the objects by refering them by their hierical location?

ie in the documention is shows:

transform.Find("Hand").GetComponent(OtherScript).foo = 2;

Assuming Hand was a direct child of the transform , could the above be written as:

transform.hand.OtherScript.foo=2;

(sorry for the newbie question)

Nope, transforms don’t work like that (sorry). You can, however, iterate through a Transform component to access all its children-

for (var trans : Transform in transform)
{
     // do something to trans
}

If you wanted to set something like that up, however, you could have a Transform variable called ‘hand’, and an OtherScript variable called ‘bar’, then assign them in the inspector window. You would then be able to access them like-

Debug.Log(hand.position);
bar.foo = 7;