I\'m building a node
scraper that uses cheerio
to parse the DOM
. This is more or a vanilla javascript question though. At one part of
If you aren't doing some kind of numeric comparison of the length property, it's better not to use it in the if statement, just do:
if(theHref){
// do stuff
}else{
// do other stuff
}
An empty (or undefined, as it is in this case) string will evaluate to false (just like a length of zero would.)