The "unexpected ++" error in jslint

KdgDev picture KdgDev · Jun 8, 2010 · Viewed 51.5k times · Source

What is the best practice for that then?

Jslint explains that it "adds confusion". I don't see it really...

EDIT: The code, as requested:

  var all,l,elements,e;
  all = inElement.getElementsByTagName('*');
  l = all.length;
  elements = [];
  for (e = 0; e < l; (e++))
  {
    if (findIn)
    {
        if (all[e].className.indexOf(className) > 0)
        {
            elements[elements.length] = all[e];
        }
    } else {
        if (all[e].className === className)
        {
            elements[elements.length] = all[e];
        }
    }
  }

Answer

unomi picture unomi · Jun 9, 2010

Use i += 1 instead, if you want to follow jslint's advice.