Nodejs String Capitalize ucFirst()

Here you can find the source of ucFirst()

Method Source Code

String.prototype.ucFirst = function(){
    var string_array = this.split(' ')
    _.each(string_array,function(word, key){
            var word_array = word.split('')
            var fChar = word_array.shift()
            var ucFWord = fChar.toUpperCase()+word_array.join('');
            string_array[key] = ucFWord/*from  w w w .  ja v a  2 s  .  c  o  m*/
    })
    return string_array.join(' ')
}

Related

  1. toCapitalCase( allCapsWordLength )
    var ID_DELIMITER = '-';
    function sanitizeString( input ) {
        return input.split( /\W/g )[1];
    String.prototype.toCapitalCase = function( allCapsWordLength ) {
        if ( isNaN( parseInt( allCapsWordLength ) ) ) {
            allCapsWordLength = 3;
        var words = this.split(' ');
    ...
    
  2. toCapitalizeCase()
    String.prototype.toCapitalizeCase = function () {
        return this.charAt(0).toUpperCase() + this.slice(1);
    };
    
  3. ucFirst()
    String.prototype.ucFirst = function() {
        var str = this;
        if(str.length) {
            str = str.charAt(0).toUpperCase() + str.slice(1);
        return str;
    };
    
  4. ucFirst()
    String.prototype.ucFirst = function () {
      return this.charAt(0).toUpperCase() + this.slice(1);
    };
    
  5. ucFirst()
    String.prototype.ucFirst = function()
        return this.charAt(0).toUpperCase() + this.substr(1);
    
  6. ucFirst()
    String.prototype.ucFirst = function() {
      return this.substr(0, 1).toUpper() + this.substr(1);
    };
    
  7. ucFirst()
    String.prototype.ucFirst = function () {
        return this.substr(0,1).toUpperCase()+this.substr(1);
    };
    
  8. ucFirst()
    String.prototype.ucFirst = function(){
      result = this.replace(/^\w/g, function(x){
        return x.toUpperCase();
      });
      return result;
    };
    
  9. ucFirst()
    String.prototype.ucFirst = function() {
      return [this.charAt(0).toUpper(), this.slice(1)].join('');
    };