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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:03:00+00:00 2026-06-05T07:03:00+00:00

I have some objects: var obj1 = new Obj1(), obj2 = new Obj2(), …

  • 0

I have some objects:

var obj1 = new Obj1(),
    obj2 = new Obj2(),
    ...

and two arrays:

objecs.push(obj1, obj2,...);
defaultObjects.push(obj1, obj2, ...);

During the game loop objects array changes, but defaultObjects does not.
When the game needs to be restarted, I need to make objects equal to defaultObjects (just like it was in the beginning).
if I do this:

objects = defaultObjects.slice(0)

does it mean that objects[0] and defaultObjects[0] are now pointing at the same object obj1, but there is no connection between objects and defaultObjects so I get what I need?

  • 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-05T07:03:03+00:00Added an answer on June 5, 2026 at 7:03 am

    That is correct. slice will return you a new array.
    However, as you have mentioned, array elements will still be referring to the same objects. I.e. changing any object from one array will lead to its change in another.

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

Sidebar

Related Questions

I'm making a game where I have must have some objects like weapons and
Assume that you have two IEnumerbale objects. How we can merge them (in some
I have a LINQ query that returns some object like this... var query =
Let's have an example: using (var someObject = new SomeObject()) { var someOtherObject =
I have some objects which will be used in the same manor. This object
I have some NSDictionary objects stored in an NSArray called telephoneArray . I fetch
Basically I have some class objects, each with three properties. Once one class object
I'm working on a class-based php web app. I have some places where objects
For one of my software, I might need to have to add some objects
I have some classes that represent immutable objects (Quantity, Price, Probability). Is there some

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.