Sharing a little gem - ASP.NET Javascript String.format

When you are working with ASP.NET 2.0, Microsoft injects quite a bit of Javascript framework stuff.  Most ASP.NET developers don't dive into these libraries and thus never know the gems that Microsoft has added in their Javascript framework.

I'm just going to share a little gem today, Microsoft has implemented a full version of the String.format in Javascript - in the same style as the .NET counterpart.

So in Javascript, you can do:

 

String.format( "{0:d}", new Date() );

or

String.format( "{0:c}", 100 );

Do watch out these values are localized to your current culture - whether it's [en] or [en-us] or [en-au], these are set in your browser's settings.

Have fun!

jliu