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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:42:59+00:00 2026-06-07T00:42:59+00:00

I have a class, looks something like this: function MyClass() { this.array1 = [];

  • 0

I have a class, looks something like this:

function MyClass()
{
    this.array1 = [];
    this.array2 = [];
    this.add_item = function( i_x, i_y, i_item )
    {
        var pos = { "x" : i_x, "y" : i_y, "data" : i_item };
        this.array1.push( pos );
        this.array2.push( pos );
    }
    return this;
}

What is happening is that when I put a breakpoint at the second row of the add_item method (the this.array1.push row) both array1 and array2 already have the pos item! When I step forward one step, both arrays receive the pos item again!

The unlikely answer is that this is a bug in Firefox. I experimented a bit earlier with prototyping in methods into Object, but then read that that could lead to problems with for-each-loops. What could be causing this? Is the old code still bouncing around in there? I need a clue. I’ve removed all Array and Object prototype code I had. I’ve restarted firefox. Nothing helps. Any ideas?

  • 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-07T00:43:01+00:00Added an answer on June 7, 2026 at 12:43 am

    It turns out the problem was with the firebug debugger. It was not showing the actual array. I’m not sure what it is showing, but I implemented my own object-printing-method (that handles cyclic object references) and it turns out the arrays are correct.

    phew thought I was going nuts there for a while.

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

Sidebar

Related Questions

I have a function which looks something like this, it returns a noncopyable class
I have a class which looks something like this: class MyClass { public: //
I have a module that looks something like this: def __myFunc(): ... class MyClass(object):
I have a templated container class that looks something like this: template <class ItemType>
I have a program that looks something like this: public partial class It {
I have a model that looks something like this: public abstract class Parent {
I have a Hibernate mapping that looks something like this: <class name=MyEntity> <set name=scalarSet
Good Day, I have a Hibernate mapping that looks something like this: public class
I have a class that looks something like this: class Foo { protected $_arr
Let's say I have a class that looks something like this: class Foo(Prop1:Int, Prop2:Int,

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.