Head First into Unity with UnityScript
Written by Tonio Loewald (a.k.a. podperson)
3) You must declare variables before using them. You can, and generally should, explicitly declare variables as having types (helps code to run faster, detects some errors at compile-time -- which is excellent, and others at run time -- which is less excellent).
3a) You can (and often should) explicitly scope variables as private, static, etc.
3b) Unity will implicitly type a variable if you assign it a value when you declare it. So:
integer types (including int, uint32, etc.)
And Unity's many built-in classes (e.g. Vector3)
a) The name of the class is the name of the script file (so if it's foo.js you can instance it elsewhere by saying var x = new foo()).
b) Certain "magic" method names will in fact implement event handlers (e.g. Start(), FixedUpdate() etc.). In any event, a function declaration is a method of the class you've written/
c) Code written outside function definitions inside your file are executing in the class's body. Variables declared in it are members of the class.
d) static functions and variables in a class are, in essence, class functions and variables.
7a) Unity 2.x supports eval() -- possibly only in the dev environment (?). Don't use eval Smile
Scripting errors will show in Unity as a "red x icon" in the window status bar. Click on the icon to bring up the console, showing a list of errors, which should be both informative and lead you to the line in the script that caused the problem.
The print() function will produce messages in the status bar and console.
Although Unity does not have a conventional "stop, watch, and step" debugger, the editing GUI is completely live when running projects in the development environment (e.g. instances created at runtime appear in the browsers and you can click on them and look at their internal state).