Javascript String ucfirst(str)

Description

Javascript String ucfirst(str)


(function() {/*from ww w  .jav  a  2 s.  c o  m*/

/**
 * Make a string's first character uppercase
 * @param  {string} str The string to modify
 * @return {string}     Same string with first letter uppercased
 */
String.prototype.ucfirst = function(str) {
    str += '';
    var f = str.charAt(0).toUpperCase();
    return f + str.substr(1);
};


})();



PreviousNext

Related