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 9144279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:13:50+00:00 2026-06-17T10:13:50+00:00

I am writting some javascript class code, which will accept array of ‘Steps’ objects,

  • 0

I am writting some javascript class code, which will accept array of ‘Steps’ objects, and will perform steps navigations.

What I am planning to do is , whenever Next() method is called, it should call a callback function before going to next step.

pseduo code

var mySteps = {[1,"Step1","javascriptCallbackStep1"],[2,"Step2","javascriptCallbackStep2"]};
var StepsManager.Next = function() {
  var step = getcurrentStep();
  if(step.javascriptCallbackStep1())
      //go next
}

this javascriptCallbackStep1 is not getting called, any help with this little details will be greatly appreciated.

Thanks,

[Update:Answer]
I think I didnt ask it properly.

What I was trying to do was passing function name as string to javascript class property , and expecting it to be called.

passedValue = "MyFunctionName";
Class.Validate = passedValue;

And then finally for calling it was trying soemthing like below

Class.Validate();

Offcourse it was not working as in Class.Validate there was string, and there was no specification that treat it as function and not string.

So I successfully tried following

Class.Validate = function () { return window[passedValue](); };

It worked. Thanks anyways.

  • 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-06-17T10:13:52+00:00Added an answer on June 17, 2026 at 10:13 am

    Javascript needs to be given a reference to a function to execute it. Passing the function itself or doing what @paul suggests is the surest way to write code that acts predictably/reliably.

    You shouldn’t be passing the function name as a string, but know that you can:

    function someFunction(name) { return "hello " + name; }
    var fn = window["someFunction"]; 
    console.log(fn("test"))
    

    Change window to the namespace where the function lives

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

Sidebar

Related Questions

I am writing some objects (classes I guess) in javascript. Class B inherits from
I'm writing some Javascript code that generates an XML document in the client (via
I'm writing some Javascript code and I'm trying to change the current page as
I'm writing a simple Javascript library that makes use of some WebGL code. I'd
I'm writting an app which has to post some data on a webservice. To
I'm writing some MVC JavaScript code using Prototype. The problem is that when I
I am writing some oop javascript code. I have a couple of instances of
I am writing code that will use AJAX requests to get some HTML code
I just wrote some JavaScript code that follows along with what I believe to
Does setTimeout work from WITHIN setInterval ? I'm writing some JavaScript to animate some

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.