Passing Parameters out by Reference?
![Stretch65](https://secure.gravatar.com/avatar/4ac8e70dacce16d2ff5a602d714c5cf0?&r=pg&s=100&d=https%3A%2F%2Fvanillicon.com%2F4ac8e70dacce16d2ff5a602d714c5cf0_100.png)
Surely it's possible to pass parameters out of a function by reference, isn't it?
Example: If select an item in my scene and run this:
(function() { var oPrimarySel = null; function doStuff(oNode) { oNode = Scene.getPrimarySelection(); } doStuff(oPrimarySel); print('oPrimarySel = '+oPrimarySel);})()
I get "oPrimarySel = null"
Comments
Rob provides a link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions#Description and a quote
you need the function to have a
return oNode;
line, and then the caller nees to assign the return value to a variable
var oOutcome = doStuff(oPrimarySel);
Rob adds that if you created a new object and passed that, then you could store the result in a member of that object and it would be accessible (as I understand the process, thinking of C-type programming, you would pass a variable containing a pointer - the object pointed to is outside the scope of the function and can be changed in a pesistent way, but the pointer is still local to the function and changing that to point to a different object of the same type would not chnage the object available in the calling code).