JavaScript
throw
anything, but try to use an Error
object: function factorial (x) { if (x < 0) { throw new Error("Negative argument" + x); } for (var f = 1; x > 1; f *= x, x--); return f; }
catch
.try { //do stuff } catch (e) { //only one catch, so you might need to: switch (e.name) { case 'Error': //stuff break; default: throw e; } } finally { //statements that always get executed }
31 of 65