Is it possible to invoke a function using a string in JavaScript?
I have a scenario where I receive a string as the function name, and I need to call and run that function. However, my current code is not working as expected.
Below is the code snippet I tried:
linkAction(attr,url){
if(attr == 'click'){
debugger
let eventName = Object.keys(url)[0];
this[eventName];
}else{
window.open(url, "_blank");
}
}
Unfortunately, this code does not successfully call the method as intended.