A small problem with javascript

Today, when I was writing php code, I suddenly found

$b="test";
$par1=1;
$par2=2;
$a->{$b}($par1,$par2);

so how to implement it in javascript?

-sharpeval().eval().
var f=data.type;//1string
console.log(f);
toastr.f(data.message);//..
Jun.25,2021

toastr[f](data.message)
Menu