The following three language constructs help with debugging. They should obviously be complemented by a proper debugger:
The console API provides more debugging help and is documented in more detail in The Console API. Exception handling is explained in Chapter 14.