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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:57:46+00:00 2026-06-09T15:57:46+00:00

I wonder how memory is managed in V8. Take a look at this example:

  • 0

I wonder how memory is managed in V8. Take a look at this example:

function requestHandler(req, res){
  functionCall(req, res);
  secondFunctionCall(req, res);
  thirdFunctionCall(req, res);
  fourthFunctionCall(req, res);
};

var http = require('http');
var server = http.createServer(requestHandler).listen(3000);

The req and res variables are passed in every function call, my question is:

  1. Does V8 pass this by reference or does it make a copy in memory?
  2. Is it possible to pass variables by reference, look at this example.

    var args = { hello: 'world' };
    
    function myFunction(args){
      args.newHello = 'another world';
    }
    
    myFunction(args);
    console.log(args);
    

    The last line, console.log(args); would print:

    "{ hello: 'world', newWorld: 'another world' }"
    

Thanks for help and answers 🙂

  • 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-09T15:57:47+00:00Added an answer on June 9, 2026 at 3:57 pm

    That’s not what pass by reference means. Pass by reference would mean this:

    var args = { hello: 'world' };
    
    function myFunction(args) {
      args = 'hello';
    }
    
    myFunction(args);
    
    console.log(args); //"hello"
    

    And the above is not possible.

    Variables only contain references to objects, they are not the object themselves. So when you pass a variable that is a reference to an object, that reference will be of course copied. But the object referenced is not copied.


    var args = { hello: 'world' };
    
    function myFunction(args){
      args.newHello = 'another world';
    }
    
    myFunction(args);
    console.log(args); // This would print:
        // "{ hello: 'world', newHello: 'another world' }"
    

    Yes that’s possible and you can see it by simple running the code.

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

Sidebar

Related Questions

I wonder if this affects performance or memory consumption a lot. I need an
I wonder if this piece of code will cause memory leakage? because I still
I am learning parallel programming by myself. I wonder if distributed memory is always
I wonder if someone can help me out with regards to the memory management
I have a process/Linux, which runs out of memory very soon, and I wonder
I have a question regarding AS3 memory management I wonder if anyone could help
After reading this question I started to wonder: is it possible to have a
I wonder where constant variables are stored. Is it in the same memory area
Apple's Advanced Memory Management doc is pretty well written and precise, but I wonder
I wonder if construction like this (initialization list) has well defined EO (evaluation order):

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.