I'm having difficulty getting out of a foreach when the internal if condition is met, I followed the recommendations in the official JQuery documentation that says to give a return false
but it still does not work, follow 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;
}
});
}
Is something missing, so I can interrupt this foreach?