Fork me on GitHub

JSLint Error Explanations

JSLint will hurt your feelings. It's time to make them better!


Function declarations should not be placed in blocks

When do I get this error?

JSHint will throw the "Function declarations should not be placed in blocks" error when it encounters a function declaration inside a block statement. In the following example we attempt to declare the example function if some condition evaluates to true:

This is the JSHint equivalent of the "Function statements should not be placed in blocks" error from JSLint. More detail can be found on the page for the JSLint message.


James Allardice

This article was written by James Allardice, an enthusiastic young JavaScript developer at Global Personals (we're looking for developers so please apply). He is passionate about writing clean, maintainable JavaScript and uses JSHint every day to help achieve this.

You can follow him on Twitter, fork him on GitHub and find him on Google+.


Proceeds generated by this site are donated to help advance other open source projects



comments powered by Disqus