I'm not sure if that's so important but I like clean code so here's my question :
I use node.js with express. I have declared routes that render views :
app.get("/", function(req, res){
return res.render("index.jade");
});
Can I remove the "return" keyword like this :
app.get("/", function(req, res){
res.render("index.jade");
});
I've found lots of examples with both syntax. Don't know which one to use.
Thanks.
In your case it doesn't matter at all. However using return is a common method when using conditionals. For example:
app.get("/", function(req, res){
if(req.whatever) {
// Using return here will cause any code after to not be run
return res.render("index.jade");
}
// Default action
res.render("default.jade");
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With