Optimize ucFirst by using charAt
authorKrinkle <krinkle@users.mediawiki.org>
Thu, 1 Sep 2011 17:25:33 +0000 (17:25 +0000)
committerKrinkle <krinkle@users.mediawiki.org>
Thu, 1 Sep 2011 17:25:33 +0000 (17:25 +0000)
resources/jquery/jquery.mwExtension.js

index 7b37bb7..023ea7f 100644 (file)
@@ -12,7 +12,7 @@
                                        '' : str.toString().replace( /\s+$/, '' );
                },
                ucFirst: function( str ) {
-                       return str.substr( 0, 1 ).toUpperCase() + str.substr( 1 );
+                       return str.charAt( 0 ).toUpperCase() + str.substr( 1 );
                },
                escapeRE: function( str ) {
                        return str.replace ( /([\\{}()|.?*+\-^$\[\]])/g, "\\$1" );