app.get("/", function(req, res) {
if( some_func() == 0 ) {
res.send("some_func() returned zero!");
/* leave function(req, res) */
}
res.send("Everything OK.")
});
How would that work in Node.js?
You’re looking for the
returnstatement.Or just use an
else:N.B. Perl’s
lastis not likereturn; it is analogous tobreakin C-like languages (C, C#, Java, JavaScript, etc.), and is used to exiting loops and switches – not functions.