It turns out this does exactly what I want it to do. But HTML does not replace the function call with a value, which is why I got confused. The correct value IS passed into the array though. I am leaving this question here in case others have the same issue.
I have some javascript:
<script type="text/javascript">
var $SAT = $SAT || [];
$SAT.push(['setContent','subtype','sub']);
$SAT.push(['setUser', '1234']);
</script>
but I want to replace ‘sub’ with a function call to retrieve the value by other means, like so:
<script type="text/javascript">
function getValue() {
return 'Some Value';
}
var $SAT = $SAT || [];
$SAT.push(['setContent','subtype',getValue()]);
$SAT.push(['setUser', '1234']);
</script>
however the resulting code does not replace the getValue() function call with ‘Some Value’ as I would have expected. Does anybody know why, and what I need to do to fix this?
Much appreciated!
Here’s an untested idea: