douglascrockford/JSLint — Issue #93: Body of a for-in
Author: roderickObrist
Created: 2011-12-29 03:52:34+00:00
State: open

I keep looking at this code wondering where I went wrong, but I cant see it.

/*global Form*/
Form.prototype.toHTTPString = function () {
"use strict";
var fields = this.fields,
getString = '',
i;
for (i in fields) {
if (fields.hasOwnProperty(i)) {
getString += (i + '=' + encodeURIComponent(fields[i].elm.attr('value')));
}
getString += '&';
}
return getString.slice(0, -1);
};

If you copy and paste that into JSlint it spits out:

Error:

Problem at line 7 character 5: The body of a for in should be wrapped in an if statement to filter unwanted properties from the prototype.

If this is not a bug, and I'm just plain blind you have my apologies in advance.