Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4017582
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:52:43+00:00 2026-05-20T09:52:43+00:00

With reference to the code from here With reference to the addListener(instance:Object, eventName:string, handler:Function)

  • 0

With reference to the code from here

With reference to the addListener(instance:Object, eventName:string, handler:Function) function. Here we pass in a handler. So toggleBounce is called when you click it.

I could also change it to var toggleFn = function toggleBounce() {....) and pass in toggleFn

My question is, can I pass in a function which takes parameters, for example if I wanted the handler to be a zoom(mapOptions.zoom -5) or similar function.

I know this is essentially a ‘how do you pass functions as parameters’ question but I just can’t get it to work with different combinations.

function initialize() {
  var mapOptions = {zoom: 13, center: stockholm };
  map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);

  marker = new google.maps.Marker({map:map,position: parliament });
  google.maps.event.addListener(marker, 'click', toggleBounce);
}

function toggleBounce() {
  if (marker.getAnimation() != null) { marker.setAnimation(null);} 
  else {marker.setAnimation(google.maps.Animation.BOUNCE);}
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T09:52:44+00:00Added an answer on May 20, 2026 at 9:52 am

    You can pass a anonymous function:

    functionToPassTo(function(){ zoom(mapOptions.zoom -5) });
    

    You can also pass variables:

    var options = "something";
    functionToPassTo(function(){ zoom(options) });
    

    The only other way would be to store the function in a variable:

    var options = "something",
    func=function(){ zoom(options) });
    functionToPassTo(func);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is the code from the class within which I am trying to reference
I am receiving an error on the following line of code: Object reference not
Doing code analysis of the project and get the message Reference-counted object is used
Taken from here: http://docs.jboss.org/hibernate/stable/core/reference/en/html/persistent-classes.html#persistent-classes-equalshashcode I tend to use List since Criteria returns List ,
I've learnt from here that a const reference can be made out of an
I was looking through some code from a firefox extension (here: https://github.com/mozilla/prospector/blob/master/oneLiner/bootstrap.js#L34 ) and
I have tried a reference code from the web to load a particular element
I downloaded a sample code from here: http://gallery.expression.microsoft.com/ShowHideWithFlip Now my problem is that i'm
I'm trying to use a component I downloaded from code project ( here's the
Ho do you reference code inside an AJAX tabcontainer? Is there an easy way?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.