【发布时间】:2012-08-09 00:57:25
【问题描述】:
我想知道 V8 中是如何管理内存的。看看这个例子:
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);
req 和 res 变量在每个函数调用中都会传递,我的问题是:
- V8 是通过引用传递它还是在内存中复制?
-
是否可以通过引用传递变量,看这个例子。
var args = { hello: 'world' }; function myFunction(args){ args.newHello = 'another world'; } myFunction(args); console.log(args);最后一行,
console.log(args);将打印:"{ hello: 'world', newWorld: 'another world' }"
感谢您的帮助和回答:)
【问题讨论】:
标签: javascript node.js pass-by-reference v8