express.Router()

Created on 17 Aug 2016  路  3Comments  路  Source: expressjs/express

A function with a name starting with an uppercase letter should only be used as a constructor.

The sentence const router = express.Router(); issues with AirBnb eslint.

4.x question

Most helpful comment

Yea, looks like a non-issue to me :) express.Router _is a constructor_; you can do new express.Router(). The new is optional, just like many of the object constructors in JavaScript itself (i.e. Error('oh no!') and new Error('oh no!') are identical, as the new keyword is optional).

All 3 comments

Can you provide more context? This isn't really a bug, just an issue with your chosen linting. Why not just use new?

Yea, looks like a non-issue to me :) express.Router _is a constructor_; you can do new express.Router(). The new is optional, just like many of the object constructors in JavaScript itself (i.e. Error('oh no!') and new Error('oh no!') are identical, as the new keyword is optional).

Ok, thanks for the quickly response!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AndrewEQ picture AndrewEQ  路  4Comments

Domiii picture Domiii  路  3Comments

HafidAbnaou picture HafidAbnaou  路  3Comments

ZeddYu picture ZeddYu  路  3Comments

guyisra picture guyisra  路  3Comments