I think we both understand how parameters are passed in JS, we just disagree on the terminology. It sounds silly to me to say that an object is "passed by value" when I can mutate the original object from within the function (i.e. the function has side effects).
Going by your definition, only languages like PHP have something like "passing by reference", where using the assignment operator (=) affects the original variable.
I think a better term for how objects are passed in JS / Python / Java ... is 'call by sharing'.
If you say that in JS, both Numbers and Objects are passed by value, it sounds really misleading with regard to purity and side effects : in one case the function is pure, in the other it's not, and you have to watch out for mutation when you pass your object to a function.
Anyway, let's not bicker about it, I dont want to argue endlessly on terminology, as long as we both understand what's happening.
objects are passed by a copy of the reference. this means reassigning to the parameter will indeed have no effect on the original object; however, modifying the object's properties will affect the original object
Yes It happen before. People think that magazine is like journals or stuff to read. But in this context is slots for the weapons.
O ponto é que você deve descobrir quantos pentes cada agente do bope deve possuir em uma determinada missão. A palavra magazines é relacionada a pentes (balas) e não a revistas.
Por isso a cada rua que eles cruzam, eles atiram. Entendeu?
A magazine is a part of a gun that includes bullets. I was confused by this word (magazine) because I knew only one meaning of this word. It's a quite easy kata.
Best of the best is COBOL:
(works with numbers, strings... whatever)
I think we both understand how parameters are passed in JS, we just disagree on the terminology. It sounds silly to me to say that an object is "passed by value" when I can mutate the original object from within the function (i.e. the function has side effects).
Going by your definition, only languages like PHP have something like "passing by reference", where using the assignment operator (
=
) affects the original variable.I think a better term for how objects are passed in JS / Python / Java ... is 'call by sharing'.
If you say that in JS, both
Number
s andObject
s are passed by value, it sounds really misleading with regard to purity and side effects : in one case the function is pure, in the other it's not, and you have to watch out for mutation when you pass your object to a function.Anyway, let's not bicker about it, I dont want to argue endlessly on terminology, as long as we both understand what's happening.
-- deleted
you CAN change the object passed to your function precisely because it is passed by reference, not by value ...
are they really ?
objects are passed by a copy of the reference. this means reassigning to the parameter will indeed have no effect on the original object; however, modifying the object's properties will affect the original object
Yes It happen before. People think that magazine is like journals or stuff to read. But in this context is slots for the weapons.
O ponto é que você deve descobrir quantos pentes cada agente do bope deve possuir em uma determinada missão. A palavra magazines é relacionada a pentes (balas) e não a revistas.
Por isso a cada rua que eles cruzam, eles atiram. Entendeu?
A magazine is a part of a gun that includes bullets. I was confused by this word (magazine) because I knew only one meaning of this word. It's a quite easy kata.