I have a variable that is like this:
var dependentVar = "'<%: somevalue %>', '<%: somevalue2 %>', '<%: somevalue3 %>'";
Which must be passed into a another variable
var newVar = new var.Function(dependentVar).
The function is like
function(somevalue, somevalue2, somevalue3)
The problem I am facing is that when the variable is passed – it passes like this
"'123123', '123123123', '123123123'"
and it errors due to the " ? How can I fix this ?
Well I wouldn’t really do it this way, but you could do this:
I guess it’s not that bad. You could also do
The first way does have the advantage that it’d work for any number of values, assuming the function was prepared to deal with that. (If it were, and there were no other reason for the function to be written that way, it could be changed to operate on an array directly.)
edit — OK, if you need to call a function via an object property, you’d do this:
The first argument to “apply” will make sure that “tmp” is the value of
thiswhen “someFunction” is called.