In javascript, any expression can be converted to a true or false value and, therefore, it is valid in the place of comparison. Values ββthat are false in javascript,
false0"" (empty line)nullundefinedNaN
In this case, it lengthrefers to a numerical value, and if it is evaluated as 0, then it will be considered false. Otherwise it will be true.