javascript - Why a null result is freezing the script and how to avoid it? -
when use below code:
if(string.match(/td>0/g).length == 8) { /*do something*/ }
and no /td>0/
matched, returns null
result prevents script below executing.
i know why code freezing, , how avoid , find solution or alternative .match()
?
try this(more recommended):
var matching=string.match(/td>0/g); if( matching != null && matching.length === 8) { /*do something*/ }
use ===
instead of ==
.
Comments
Post a Comment