Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (47.6k points)

I'm looking for a good JavaScript equivalent of the C/PHP printf() or for C#/Java programmers, String.Format() (IFormatProvider for .NET).

My basic requirement is a thousand separator format for numbers for now, but something that handles lots of combinations (including dates) would be good.

I realize Microsoft's Ajax library provides a version of String.Format(), but we don't want the entire overhead of that framework.

1 Answer

0 votes
by (106k points)

The JavaScript equivalent to printf/String.Format is to use template strings see the code below:

let soMany = 10;

console.log(`This is ${soMany} times easier!`);

Related questions

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...