Fork me on GitHub

JSLint Error Explanations

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


Only properties should be deleted

When do I get this error?

JSLint will throw the "Only properties should be deleted" error when it encounters the delete operator when its operand does not appear to be an object property. In the following example we declare a variable x and then attempt to delete it:

Why do I get this error?

This error is raised to highlight code that probably doesn't work as you expect it to. The delete operator will only delete the properties of objects. It cannot "delete" variables or anything else. Here's a valid use of the delete operator. Notice how this time there are no JSLint errors:

It's useful to remember that the delete operator will return true in all cases, unless its operand is a property that cannot be deleted.


comments powered by Disqus