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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:32:34+00:00 2026-06-09T20:32:34+00:00

I was trying to understand passing of variables and objects in JavaScript, and came

  • 0

I was trying to understand passing of variables and objects in JavaScript, and came across this page.

It is explained that JavaScript objects are passed by value, but the value itself is a reference. Though I understood what was happening in the examples given on that page, I am still confused so as to why. Can anyone please explain what does “value itself is a reference” mean?

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

    Some languages have a “pass by reference” concept for function arguments which means that when you call a function and pass in a variable by reference the function can modify the original variable to hold some other value – it has a reference to the original variable.

    With “pass by value” when you call a function and pass in a variable the function only gets the value so can’t change the original variable that was passed in.

    JS only has “pass by value”, however when you pass an object as a parameter the “value” is a reference to the original object such that the function can modify, create or delete properties of that object, but the function can’t modify the original variable to refer to some other object or value.

    Example:

    function changeObj(someObj) {
        someObj.a = 1000;
        someObj.c = "test";
    
        someObj = { "x" : 5 };
        console.log(someObj);   // { "x" : 5 }
    }
    
    var o = { "a" : 1, "b" : 2 };
    changeObj(o);
    console.log(o);   // { "a" : 1000, "b" : 2, "c" : "test" }
    

    The code I’ve shown creates a variable, o, that references an object with a and b properties. It then calls the function changeObj and passes in o. The function changes the value of the a property and creates a new c property – the function is modifying the same object that variable o refers to because it has a reference to that object. But then the function assigns someObj equal to a completely new object. This does not affect o at all because the function only had a reference to the object o was pointing at, it didn’t have access to the o variable itself.

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

Sidebar

Related Questions

Trying to understand the options for will_paginate's paginate method: :page — REQUIRED, but defaults
Trying to understand PNG format. Consider this PNG Image: The Image is taken from
Trying to understand Ruby a bit better, I ran into this code surfing the
Trying to understand the math of this code snippet. A token is provided which
Im trying to understand how class generics work and this bit just doesnt make
I'm just trying to understand passing by reference in PHP by trying some examples
I've been programming for a few years but I'm new to JavaScript. I'm trying
I understand that "string-eval" can be used for it. But I am looking for
I have a javascript file from a wordpress plugin that I'm trying to modify.
I'm trying to solve the problem of passing a 2-dimensional table into JavaScript AJAX

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.