Using JSHint with Express.js / 'delete' (a reserved word) Using JSHint with Express.js / 'delete' (a reserved word) node.js node.js

Using JSHint with Express.js / 'delete' (a reserved word)


In Express.js, use del instead of delete.

app.del('/api/users/:userid', function deleteUser(req, res, next)


Another way to solve this would have been to use bracket notation instead of dot notation.

app['delete']('/api/users/:userid', function deleteUser(req, res, next) {  /* function body */});

This sort of work around was necessary in the past when working with IndexedDB which defines both .delete and .continue methods.

These days this sort of workaround should not be necessary. Ever since ES5 JavaScript has allowed property names to use reserved words. For a long time jsHint defaulted to assuming your code was ES3, but starting with version 2.0.0 it defaults to assuming it is ES5 and will not complain about reserved words being used as property names.


In JSHint 1.1.x you can set the es5 option for jshint, and it will allow you to use reserved words as properties per the ES5 specification.

As of JSHint 2.0 es5 option is the default and you should be allowed to use reserved words as properties.

For more info you can head over to http://www.jshint.com/docs/#options