function throwIfTrue(param) {
try {
if (param)
throw new Error("test exception");
}
catch (e) {
console.log("catch");
}
finally {
console.log("finally");
}
}
throwIfTrue(true);
//печатается: "catch" и "finally"
throwIfTrue(false);
//печатается только "finally"