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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:15:35+00:00 2026-05-25T19:15:35+00:00

An array of functions, [fn1,fn2,…] , each returns through a callback, passing an optional

  • 0

An array of functions, [fn1,fn2,...], each “returns” through a callback, passing an optional error. If an error is returned through the callback, then subsequent functions in the array should not be called.

// one example function
function fn1( callback ) {
   <process>
   if( error ) callback( errMsg );
   else callback();
   return;
}

// go through each function until fn returns error through callback
[fn1,fn2,fn3,...].forEach( function(fn){
  <how to do this?>
} );

This can be solved other ways, but nonetheless would love the syntactic dexterity to use approach.

Can this be done?


as per correct answer:

[fn1,fn2,fn3,...].every( function(fn) {
  var err;
  fn.call( this, function(ferr) { err = ferr; } );
  if( err ) {
     nonblockAlert( err );
     return false;
  }
  return true;
} );

seems this has room for simplification.

for me, much better approach to solve this type of problem – it’s flatter, the logic more accessible.

  • 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-25T19:15:35+00:00Added an answer on May 25, 2026 at 7:15 pm

    If I understand your question correctly and if you can use JavaScript 1.6 (e.g. this is for NodeJS), then you could use the every function.

    From MDN:

    every executes the provided callback function once for each element
    present in the array until it finds one where callback returns a false
    value. If such an element is found, the every method immediately
    returns false. Otherwise, if callback returned a true value for all
    elements, every will return true.

    So, something like:

    [fn1, fn2, fn3, ...].every(function(fn) {
        // process
        if (error) return false;
        return true;
    });
    

    Again, this requires JavaScript 1.6

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

Sidebar

Related Questions

Ok, I'm reading through a file now, line by line. I know each functions
how to loop through JavaScript Array member functions, the following code doesn't work :(
I have a for loop that runs through an array of functions and invokes
TL;DR: Adding any non-built-in functions to Array.prototype AND Function.prototype will cause the IE8 native
PHP functions such as 'array_map' take a callback, which can be a simple function
I am experimenting with calling delegate functions from a delegate array. I've been able
I need to declare an array of pointers to functions like so: extern void
As i am reading manual of php for array functions, i see that some
How to find if a value exists in an array and then remove it?
I'm trying to find the MySQL equivalent of the PostgreSQL functions array and array_to_string

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.