still new to JavaScript, I am searching for numbers in my JSON, but the JSON has a lot of null values. How can I ignore the null values in my search?
$.each(geojson.features, function (i, v) {
if (v.properties.code.toString().search((/2/i)) != -1) {
Count++;
}
});
Thanks for the help in advance.
you can do like this
if (v.properties.code && v.properties.code.toString().search((/2/i)) != -1) {
Count++;
}
first check value is not null and then search the string
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.