JavaScript template literal with back ticks not working

I am passing an object as a parameter to a function call I create during runtime

 document.getElementById("dynamicButton").setAttribute("onclick", `${dynamicFunction}(${dynimcParameter})`)})`;

The DOM requries a string so the "to string" function is still being called on the object; this results in the datatype name being passed instead of the object itself.

dynamicFunction([object Object])

How do I do this so I can have the object itself passed?

Source: Ask Javascript Questions

LEAVE A COMMENT