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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:49:06+00:00 2026-06-13T20:49:06+00:00

not a js expert so this might be a stupid question but… Why does

  • 0

not a js expert so this might be a stupid question but…

Why does the log show that the array has changed? I was expecting the array still to be a [0,0] since the method is invoked after the console.log. Also, if I try to replace the whole array like this:

this.my_array = [1,0];

the log will still show [0,0], which is something that makes more sense to me.
What’s going on?

function Y() {        
  this.my_array = [0,0];            
  this.changeIt = function() {
    this.my_array[0] = 1;
  };
}

var z = new Y;
console.log(z.my_array);
z.changeIt();

​

  • 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-13T20:49:09+00:00Added an answer on June 13, 2026 at 8:49 pm

    In some browsers (Chrome, for instance) console.log displays a live, interactive display of your array, not a point-in-time snapshot. So if you’re looking at the console after this runs, it’s been updated because of the change. Chrome also does slightly different things when you use console.log interactively in the console panel than when you use it from within a script.

    You’ll see what you’re expecting if you display a string instead:

    var z = new Y;
    console.log(z.my_array.join(", "));
    z.changeIt();
    

    That shows the point-in-time snapshot you’re expecting.

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

Sidebar

Related Questions

I've got this form working, but according to my previous question it might not
I am not an expert on the internals of C# so this question might
I know that maybe this question has been asked before, but I can't seem
I'm not an expert on http request so this question might be trivial for
I am not an expert in Git, but I have seen this done before
My question might be a stupid questions. But need to get help from experts.
This is a question which has been asked before ( large-text-and-images-in-sql ) but mainly
I'm not a MySQL expert and am having problem with this... So, I have
I expect the answer to this is already here someplace, but I was not
I'm not expert about css menus. But I know basic system to make css

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.