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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:37:24+00:00 2026-06-17T08:37:24+00:00

Well my short and easy to explain explanation can be this. I have 2

  • 0

Well my short and easy to explain explanation can be this. I have 2 arrays, FilterList and GamesReset. Whenever this function I have works and filters out some games with check boxes and a drop down menu, the function starts off with something like FilterList=GamesReset;. This functions seems to work fine until I filter out ages for the game. The function never touches GamesReset unless it’s something like while(i<GamesReset.length){} or FilterList=GamesReset;. And the only tool I use when I filter games is FilterList.splice(i,1);. Now with that, GamesReset definitely, should never change as far as I know. I have it to reset FilterList, then depending on what needs to be filtered out, it will start removing those games from the FilterList. The problem I have, is that, GamesReset also becomes filtered. Which, does not make any sense at all. So like my title, it’s just like saying b=0;, a=b;, a++;, and now b equals 1.

Now, I think that’s the best/shortest way I can reveal this problem, without overdoing it with my bad habit of explaining things to people. I have a webpage currently available if anyone would like to see whats going on in action, because I wouldn’t get what’s going on with GamesReset either if I were you, here (url removed, read edit). To get the error working, just change the age to 10 without checking any boxes. The bottom paragraph is the GamesReset array (using <br> to separate each array), and it’s the one that changes when I’m only changing FilterList in the JavaScript. The actual codes if you view the page source may be a little off compared to when I mentioned above, but it’s pretty much 100% the same thing. I also wanted to have the codes available without a url and on this page, but I can’t figure out how to do that with the html tags included.

Actually, here’s the JavaScript function. I just figured out the 4 spaces thing when my question was rejected.

function SearchFilter() {
  Games = GamesReset;
  plat = document.getElementById('platformcheck').checked;
  rpg = document.getElementById('rpgcheck').checked;
  puzz = document.getElementById('puzzlecheck').checked;
  hybo = document.getElementById('hybocollectcheck').checked;
  ages = document.getElementById('agescheck').value;
  if ((!plat) && (!rpg) && (!puzz) && (!hybo)) {
    FilterList = Games;
  } else {
    FilterList = [];
    i = 0;
    while (i < Games.length) {
      Set = '';
      Set = Games[i];
      Set = Set.split('</>');
      StrFind = Set[0];
      if (
        (plat && (StrFind.search(',platform,') > -1)) || (rpg && (StrFind.search(',rpg,') > -1)) || (puzz && (StrFind.search(',puzzle,') > -1)) || (hybo && (StrFind.search(',hybocollect,') > -1))) {
        FilterList.push(Games[i]);
      }
      i++;
    }
    // so by now, we should have the filtered array
  }
  //seperate filter for ages
  i = 0;
  while (i < FilterList.length) { //The problem should definitely start here
    Set = '';
    Set = FilterList[i];
    Set = Set.split('</>');
    StrFind = Set[1];
    if ((Math.abs(StrFind)) > ages) {
      FilterList.splice(i, 1);
    } else {
      i++;
    }
  }
  GL.innerHTML = GamesReset.join('<br>');
}

As a reminder, the problem starts when the age filter is working. And the only thing it does is FilterList.splice(i,1);. But it ends up changing GamesReset. I changed this function a bit when I added Games=GamesReset;, but that was another test to try and make sure GamesReset doesn’t get filtered like FilterList, but it still does.

EDIT: I removed my url since the answers definitely explained everything, so there’s no need for it now.

  • 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-17T08:37:25+00:00Added an answer on June 17, 2026 at 8:37 am

    It makes perfect sense since variables are just references to objects in memory. One object can have several references. Consider this:

    var a = { foo: 'bar' };
    var b = a;
    
    // b is now a reference to a and they both point to the same object
    
    b.foo = 'doe';
    alert( a.foo ); // alerts doe
    

    The same goes for arrays. So when you do FilterList = GamesReset you are not copying the array – you are just assigning the same array to another variable. Any mutations or changes made to either reference will be reflected in all references.

    To create a copy of an array you can use slice:

    FilterList = GamesReset.slice();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I understand the JS .sort() function well enough, and I have a loose grasp
Well, my website can not redirect to https://www.facebook.com/QuaFootSpa from http://quafootspa.com/ I have tried redirection
well i have a configuration like this in the components part of my config
I am new to Rails so this is probably an easy question but can't
this is my first question here so I hope I can articulate it well
Well long story short, my application needs to connect to the database in the
So long story short, im trying to build a chat application....well its already built
Well I can start the thread when I press togglebutton to ON and it
Well, I have a application which somehow requires some system resources, but how do
I have a problem that I can't figure out myself. I've tried using LEFT

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.