Skip to content
Advertisement

Substitute variables in strings like console.log

I want to substitute variables in a string like console.log does. What I want to achieve is something like this:

JavaScript

I am not able to figure out how to do that. Any help will be much appreciated.

Thank you.

Advertisement

Answer

You could prototype it to the String object. Something like this:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement