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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:14:55+00:00 2026-06-15T13:14:55+00:00

How can one pass a variable to a filter function in javascript? In this

  • 0

How can one pass a variable to a filter function in javascript?

In this case I’m trying to pass a value to variable “maxage”:

var dateFilter = function(value,maxage) { // Age in miliseconds
    if(Date.now() - value < maxage) {
        return value;
        } else {
        return false;
        }
    }

    dates.filter(dateFilter,500);

How can I pass the value 500 to the filter as maxage?

  • 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-15T13:14:56+00:00Added an answer on June 15, 2026 at 1:14 pm

    You would need to invoke Function.prototype.bind to create something similar to a default argument.

    dates.filter(dateFilter.bind( null, 500 ));
    

    dateFilter callback would then called with 500 PLUS “automatic passed in values” value, index, array.

    function dateFilter( customArgument, value, index, array ) {
        // customArgument === 500
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

can any one please tell me how to pass a variable as/by value? what
Hi can some one point me some guidance, i pretend to pass the value
I am trying to pass a variable to a method in one of my
Can some one tell me how to pass variable Y to $('a:eq(0)').click() ? I
I want to know how I can pass a variable from one page to
I am trying to pass a data from one click function to another and
I'm trying to pass a variable from one page to another using google app
I need to pass one javascript variable into a rails controller. Here is my
When starting a application, one can pass parameters to the application. But how can
How can one call a ColdFusion function, passing in attribute values as arguments, inside

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.