0
I’m having trouble getting out of a foreach when the internal if condition is met, I followed the recommendations of the official Jquery documentation that says to give a return false
but still not working, follows the code used:
if (digitado != "") {
hashModens.forEach(function (item, i) {
if ((digitado == item.Nome || digitado == item.Node || digitado == item.Mac) && item.MarkerVisible) {
let infoPosition = { lat: item.Latitude + 0.000008, lng: item.Longitude }
retornou = true;
map.setZoom(22);
map.panTo(new google.maps.LatLng(item.Latitude, item.Longitude));
item.InfoWindow.setPosition(infoPosition);
item.InfoWindow.open(map);
return false;
}
});
}
Something is missing, so I can interrupt this foreach?
There is no foreach method in jQuery, I think you confused
$.each
from jQuery with theArray.forEach
javascript– fernandosavio