Q: Call Vue 3 function by it's name in string variable In my script setup SFC I want to dynamically call another function from the same component by it's name in string variable, right now I'm doing it that way:
let functionName = "myFunction(param)";
eval(functionName);

I read on MDN docs that using eval is dangerous, I tried to use return Function but it gives me "Uncaught ReferenceError: myFunction is not defined" or "TypeError: [...] is not a function"
is there a better way or do I have to use eval?

A: What you have done here is assigned a string to the variable functionName. Though your post lacks some context, if you are just trying to call one function from another, it would look like this:
<script setup>

function myFunction(params){};
function myOtherFunction(){
   myFunction()
};

</script>

Or more like how you have it written. This is valid syntax as well:
let myFunction = (params) => {};
let myOtherFunction = (params) => {
  myFunction(params);
}


A: Define your function as property inside a literal object then call it using brackets:
const funcs={
  myFunction:function(param){
   ///
  }
}

// and now you could call it like 
funcs["myFunction"](yourArg)

