Parameters sent after function is over

Asked

Viewed 20 times

0

It’s probably a beginner’s question, but I’d like to understand what it’s for, with an even better example, what parameters are sent after a function is executed. For example, in this piece of code:

...
google.maps.event.addListener(marker, 'click', (function(marker, i) {
   return function() {
   contentIcon = '<div id="iconContent"><p>' +locations[i][0]+ '<br>' +locations[i][1]+ '<br>' +locations[i][2]+ '</p></div>';
      infowindow.setContent(contentIcon);
      infowindow.open(map, marker);
   }
})(marker, i));

What is the purpose of the ...(marker, i)); at the end? When to use?

Another example:

   ...
   function randomChar() {
      ...
      return arr[Math.floor(Math.random()*arr.length)];
   }

})(jQuery);
  • Miguel, I think this question is about the same as the other question. I marked it as duplicate. Say it if you think it’s not clear in the same.

  • Thank you Sergio, yes I was clarified. What I do now with this question?

  • Great! You can leave the question. It may be that there are others who search for words or titles you used and so have more chances to find the information they need.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.