express route return necessary or not -


i use express framework webapp. pickup codes book, looked @ code, route page.

app.post('/register', function(req, res) {   var firstname = req.param('firstname', '');   var lastname = req.param('lastname', '');   var email = req.param('email', null);   var password = req.param('password', null);    if ( null == email || email.length < 1        || null == password || password.length < 1 ) {     res.send(400);     return;   } 

what has return meaning here, necessary?

the return necessary if have more code below point in route handler function , want bypass rest of function. nothing in express @ or care value return. if @ bottom of function anyway, may omit return statement entirely.

typically, see patterns like:

  • first prerequisite checking, validation, authorization, or similar logic
  • if of fails, send , error , return function bypass main logic
  • main logic code comes next , executes if return wasn't encountered.

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

java - Using an Integer ArrayList in Android -