To run a function inside the parameter to get its string output

How to readily run a function inside the parameter to get its string output which is the same as $( … ) in bash ? e.g.

navigator.registerProtocolHandler("sms","https://example.com/foobar/?&to=%s.replace(/^\w+:(.+)$/,"$1")")

VM298:1 Uncaught SyntaxError: missing ) after argument list

How is the correct writing ?

or string concatenation, or using template literals - a string is a string, it doesn’t execute

the syntax error is because double quotes end the string, so $1 is out of the string