My main goal here is to pass a variable by reference. I have created a function that creates a buffer like this:
function createBuffer(buffer=null){
var _buff = Object.assign({}, {buff: buffer});
return buffer;
}
And I am currently using this buffer inside functions like this:
function myFunc(buff){
console.log(buff.buff);
buff.buff = "Hello World";
return;
}
Now I would like to ask if I could somehow define a getter/setter for the buffer object itself, so that I could just do this:
function myFunc(buff){
console.log(buff);
buff = "Hello World";
}
Is this possible? Or what would be the best way to pass variables by reference (besides from the one I am currently using) ?