The plus prefix converts the variable into a number. Basically, the obj.length === +obj.length
is a sanity check that obj.length really is a number. If the obj.length
was not a number, and for example a string "foo"
, then "foo" === +"foo"
would equate to false since +"foo"
comes out as NaN
.