I am having some trouble understanding the syntax in an anonymous function.
I understand that a for next loop is constructed like this
So the curly brackets defines the start and end of code that is repeated each time through the loop.
What I don't get is where is the start and end of the loop in this example
There are curly brackets that define the anonymous function, but where are the curly brackets for the for/next loop?
I am trying to construct my own event listner like this:
I want to capture i and send it as a parameter. Is my if statement part of the loop or what? And why don't we use curly brackets for the for/next loop?
I understand that a for next loop is constructed like this
Code:
for (var i = 0 i < someNumber i++) { code in here get repeated for each time in loop }
What I don't get is where is the start and end of the loop in this example
Code:
google.maps.event.addListener(marker, 'click', function() { marker.setMap(null); for (var i = 0, I = markers.length; i < I && markers[i] != marker; ++i); markers.splice(i, 1); path.removeAt(i); } );
I am trying to construct my own event listner like this:
Code:
google.maps.event.addListener(marker, 'rightclick', function() { for (var i = 0, I = markers.length; i < I && markers[i] != marker; ++i); thisMarkerNum = i; (document.getElementById("propertyTable").style.visibility == "hidden" ) ? showPropTable(marker, "boundry marker "+marker.title, thisMarkerNum):hidePropTable(); });
Comment