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

  • Home
  • SEARCH
  • 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 129071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T05:44:06+00:00 2026-05-11T05:44:06+00:00

Javascript code: function doSomething(v1,v2){ //blah; } function SomeClass(callbackFunction,callbackFuncParameters(*Array*))={ this.callback = callbackFunction; this.method = function(){

  • 0

Javascript code:

function doSomething(v1,v2){ //blah; }  function SomeClass(callbackFunction,callbackFuncParameters(*Array*))={    this.callback = callbackFunction;    this.method = function(){        this.callback(parameters[0],parameters[1])  // *.*    } }  var obj = new SomeClass( doSomething, Array('v1text','v2text') ); 

The problem is if I change function doSomething to

function doSomething(v1,v2,v3){ //blah; } 

I have to change the corresponding line (marked as //*.*) in SomeClass to

this.callback(parameters[0],parameters[1],parameters[2]); 

What can be done to avoid the (*.*) line to be changed no matter how the number of ‘doSomething’ function’s parameters is changed?

Thanks a lot!

  • 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. 2026-05-11T05:44:07+00:00Added an answer on May 11, 2026 at 5:44 am

    You probably want to use the apply method

    this.callback.apply(this, parameters); 

    The first parameter to apply indicates the value of ‘this’ within the callback and can be set to any value.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider this (rather pointless) javascript code: function make_closure() { var x = 123, y
Check out this piece of JavaScript code: (function (w, d) { var loader =
Suppose I have JavaScript code like myClass = function(){ function doSomething(){ alert(this); // this1
I have a javascript function that goes something like this: function doSomething(me) { var
javascript code: function getCheckbox(name,id){ var check = 0; var deger = option-checkbox-+id; var dom
Javascript Code YAHOO.util.Event.onDOMReady(function (ev) { var carousel = new YAHOO.widget.Carousel(container, {isCircular: true, numVisible:1}); console.log(carousel.set('navigation',
My javascript code is like this: function openWindows() { if(A is true) { window.open(URL_A);
My JavaScript code is as follows: $(document).keydown(function(event){ var move, inter; clearInterval(inter); inter = setInterval(move
This Javascript code is using the 'this' keyword inside a nested function (which is
The javascript code is like below. var ADDRESS = { checkit : function(element){ if(event.target.className

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.