Is it possible to use similar function like String.Format of C# in TypeScript?
My idea is to make some string like:
url = "path/{0}/{1}/data.xml"
depending of the logical I set {0} and {1}. Obiouslly I can replace them but I think String.Format is a clear function.
Format Specifiers Used in C%c :char single character. %d (%i) :int signed integer. %e (%E) :float or double exponential format. %f :float or double signed decimal. %g (%G) :float or double use %f or %e as required.
String. format returns a new String, while System. out. printf just displays the newly formatted String to System.
In java, String format() method returns a formatted string using the given locale, specified format string, and arguments. We can concatenate the strings using this method and at the same time, we can format the output concatenated string. Syntax: There is two types of string format() method.
%s and string We can print the string using %s format specifier in printf function. It will print the string from the given starting address to the null '\0' character. String name itself the starting address of the string. So, if we give string name it will print the entire string.
I think you are looking for back quote: ``
var firstname = 'Fooo';
var lastname = 'Bar';
console.log(`Hi ${firstname} ${lastname}. Welcome.`);
You can find the back quote on the tilde key.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With