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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:44:51+00:00 2026-06-08T09:44:51+00:00

Curious what I’m doing wrong here : employee_ids = $(‘[data-employee_id=’+employee+’]’); timestamp_ids = $(‘[data-scheduled_on=’+timestamp+’]’); var

  • 0

Curious what I’m doing wrong here :

employee_ids = $('[data-employee_id="'+employee+'"]');
timestamp_ids = $('[data-scheduled_on="'+timestamp+'"]');

var common = $.grep(timestamp_ids, function(element) {
  $.each(employee_ids, function(idx, item) {
     if ( item === element ) { console.log ("omg!") };
  });
});

This returns just the list of timestamp_ids and not that array compared against employee_ids looking for a single match.

  • 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-08T09:44:54+00:00Added an answer on June 8, 2026 at 9:44 am

    You are not using .grep correctly. Each iteration of grep should return a boolean: true to add it to the result array, false to ignore it.

    var listA = [1, 2, 3];
    var listB = [2, 3, 4];
    
    var union = $.grep(listA, function (element) {
        return listB.indexOf(element) !== -1;
    }); 
    

    Note that IE does not support .indexOf on Arrays, you will have to implement the comparison some other way.

    EDIT: if you are trying to find a single item of an array that matches some criteria, i would suggest just using a regular for loop:

    var result;
    for (var i = 0; i < yourArray.length; i++) {
        if (yourArray[i].id === employee_ID) { // whatever conditions you have
            result = yourArray[i];
            break;
        }
    }
    
    if (result) {
        // do whatever
    } else {
        // no match
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Curious as to the inode data structure differences between 128-byte ext2 and 256-byte ext3
Curious, what are you folks doing in as far as automating your unit tests
Curious question: Take this function: function something():Array { var ar:Array = []; var i:MovieClip;
Curious if anything jumps out here. But when I run this code block :
curious what the BSON::ObjectId.id.data array represents? for example [77, 145, 20, 13, 225, 96,
Curious if I'm doing this right and if not how you guys would approach
Curious about running multiple xvfb displays: I have between 10-50 instances of a script
Curious whether folks have setup 2 way transactional replication on the tables ASP.NET uses
Curious, what happens when you return keyword this from a struct in C#? For
Curious what "Toast" means? Saw this and am curious... Similar Posts How to add

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.