throw new Error("text"); // Error: text
throw new Warning("text"); // Warning is not defined
Note that unlike exceptions, this will not interrupt your code; the calling function will continue normally.
Also note that this will throw an error in any browser except for WebKits or Firefox with Firebug, because
console won't exist.
To fix that, you can include Firebug Lite, or make a fake NOP-ing