Fork me on GitHub

JSLint Error Explanations

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

Weird assignment

When do I get this error?

JSLint will throw the "Weird assignment" error when it encounters an assignment expression in which the left hand and right hand side expressions are "similar". In the following example we declare a variable x and then attempt to assign it to itself:

Why do I get this error?

This error is raised to highlight a potentially confusing and completely pointless piece of code. There are no situations in which you would need to assign something to itself.

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