Short-circuits conditionals

If you have to execute a function only if condition is true, you can use short-circuit.

// Instead of this
if (condition) {
    doSomething();
}

// You can use short-circuit
condition && doSomething();

Logical AND

In JavaScript, the logical AND operator will return true if both operands are true. It returns false in any other scenario. Here are a few simple examples:

true && true
// true
true && false
// false
false && false
// false

You can also read this

How to write middleware for Express.Js apps

Middleware functions are functions that have access to the request...

var logger = function (req, res, next) {
  console.log('logged')
  next()
}

Error handling with ExpressJS

Error Handling refers to how Express catches and processes errors...

app.get('/', function (req, res, next) {
  fs.readFile('/file-does-not-exist', function (err, data) {
})