I am new to ExtJS. I came across following piece of code:
Ext.String.format('<a href="mailto:{0}">{1}</a>',value+"@abc.com",value);
Now this will create a mailto link. But my query is that how Ext.String.format works and what else can I use it for?
Ext.String.format
:
Allows you to define a tokenized string and pass an arbitrary number of arguments to replace the tokens. Each token must be unique, and must increment in the format {0}, {1}, etc.
You can look at the source of the function and see it uses the formatRe
regex (/\{(\d+)\}/g
):
format: function(format) {
var args = Ext.Array.toArray(arguments, 1);
return format.replace(formatRe, function(m, i) {
return args[i];
});
}
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