Passing a variable by reference in javascript (using a C# script)

So I need to pass a variable by reference and I’m using Javascript.
From this answer I learned that I need to do it in C# if I want it to work in Javascript.

Now the tricky part for me is that I never used C#.

So my attempt was to write the following function in C#:

public bool SelectedBoolean (ref bool selectedVariable){
	return selectedVariable;
}

And I would like to use it in this Javascript function:

function AddStep (currentScript : List.<ScriptStep>, selectedBoolean : boolean, result : boolean){
	var step = new ScriptStep (currentScript, allScriptsList);
		step.stepType = StepType.BooleanChange;
		step.stepSelectedBoolean = addBoolean.SelectedBoolean (out selectedBoolean : boolean);
		step.stepSelectedBooleanResult = result;
	currentScript.Add(step);	
}

Trying to use the out is just giving me errors and no idea how I could fix it.
Also I realized that since the “selectedBoolean” is going through a Javascript function I guess it becomes a value automatically?
Does that mean I need to write the final function in C#?

How would I go about solving this?

Thanks in advance!

You don’t use the “ref” or “out” keywords in Unityscript; they are implied. However, classes are always passed by reference, so instead of messing with C# stuff it’s often easier if you just make a custom class for the variable type. e.g.:

class RefBool {
    var b : boolean;
    function RefBool (b : boolean) {
        this.b = b;
    }
}