Everything in JS is passed by value , where the value for objects and functions is a reference.
, , - , ( - ):
, :
x = function() { console.log('hey 1'); }
x function() that logs 1 ( )
y = x;
y function() that logs 1 ( )
x = function() { console.log('hey 2'); }
x function() that logs 2 ( ), y
y;
y function() that logs 1
, x y, , , , .
:
var pointingAtMe = { log: function() { console.log('1'); } }
var x = pointingAtMe;
var y = pointingAtMe;
x.log = function() { console.log('2'); }
y.log();