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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:28:43+00:00 2026-06-10T21:28:43+00:00

I have one array like so: peoples = [‘dick’, ‘jane’, ‘harry’, ‘debra’, ‘hank’, ‘frank’

  • 0

I have one array like so:

peoples = ['dick', 'jane', 'harry', 'debra', 'hank', 'frank' .... ]

And one containing keys like so:

keys  = [1, 6, 3, 12 .... ]

Now I could write something like this:

var peoplesStripedOfKeyPostions = [];

for(i = 0; i < peoples.length; i++){
    for(j = 0; j < keys.length; j++){
        if( i !== keys[j]){
            peoplesStripedOfKeyPostions.push( peoples[i] );
        }
    }        
}

If you can’t tell, I’m need to produce an array of people that is stripped of people at certain positions defined in array keys. I know there has to be a nifty and efficient way to do this, but I certainly can’t think of it. (array management not my forte).

Do you know a better way to do this? (If I get multiple working answers, jsperf determines the winner.)

  • 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-10T21:28:44+00:00Added an answer on June 10, 2026 at 9:28 pm
    people.filter(function(x,i){return badIndices.indexOf(i)==-1})
    

    This will become inefficient if the badIndices array is large. A more efficient (albeit less elegant) version would be:

    var isBadIndex = {};
    badIndices.forEach(function(k){isBadIndex[k]=true});
    
    people.filter(function(x,i){return !isBadIndex[i]})
    

    (note: you cannot use a variable named keys because that is a builtin function)

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

Sidebar

Related Questions

I have an array like this one $state[1]='FG'; $state[2]='BU'; $state[3]='CA'; ... $state[150]='YT' What I
for example: I have created one javascript property array model with some properties like
I have an object whose value may be one of several array types like
I have converted an array to object data like this: <?php $myobject->data = (object)Array('zero','one','two');
I have an array like the one you see at the bottom of this
I've got a class with many string arrays. I'd like to have one generic
I have 2 arrays that I would like to render in a template, one
I have two arrays. I'd like to copy ranges of data from one of
I have two arrays. I'd like to merge them into one, but remove the
I have one array that is filled by mysql_query. Values that are in this

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.