The if statement in JavaScript returns true for any number greater (or less) than zero, and false for 0 (there are many more rules beyond this which I will not mention for this question). Hence in your code snippet
if (target.length) {some stuff}
The some stuff would be evaluated if the target had a non zero length. If the target had a zero length, possibly indicating that it were empty, the some stuff content would not evaluate.