3 ms·
Compare: function(x) { x += 1; } function(o) { o.x += 1; } The first one behaves like passing by value, the second like passing by reference. Under t
by pornel 5y ago
Compare:
function(x) { x += 1; }
function(o) { o.x += 1; }
The first one behaves like passing by value, the second like passing by reference.
Under the hood the `Number` x may have been passed by reference and changed by creating a copy, or it may have been JITed to be an i32 actually passed by value, or optimized out of existence entirely. How it is actually passed ends up being an implementation detail that you can't observe from high-level perspective.