Nodejs String Capitalize ucfirst(str)

Here you can find the source of ucfirst(str)

Method Source Code

/**/*  w  w w  .  j  a v a  2s.  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);
};

Related

  1. ucfirst()
    String.prototype.ucfirst = function () {
        return this.charAt(0).toUpperCase() + this.slice(1);
    };
    
  2. ucfirst()
    String.prototype.ucfirst = function() {
      var x = this.split(/\s+/g);
      for (var i = 0; i < x.length; i++) {
        var parts = x[i].match(/(\w)(\w*)/);
        x[i] = parts[1].toUpperCase() + parts[2].toLowerCase();
      return x.join(' ');
    };
    
  3. ucfirst()
    String.prototype.ucfirst = function(){
      return this.replace(/(^[a-z])/,function(v){return v.toUpperCase();});
    };
    
  4. ucfirst()
    String.prototype.ucfirst = function() {
        return this.substr(0, 1).toUpperCase() + this.substr(1);
    
  5. ucfirst()
    String.prototype.ucfirst = function(){
      var str = this + '';
        return str.charAt(0).toUpperCase() + str.substr(1);
    
  6. firstToUpper()
    String.prototype.firstToUpper = function() {
      return this.charAt(0).toUpperCase() + this.slice(1);
    
  7. firstToUpper()
    var useful = {}
    String.prototype.firstToUpper = function() {
      return this.charAt(0).toUpperCase() + this.slice(1);
    Array.prototype.shuffle = function() {
      var currentIndex = this.length, temporaryValue, randomIndex ;
      while (0 !== currentIndex) {
        randomIndex = Math.floor(Math.random() * currentIndex);
        currentIndex -= 1;
    ...
    
  8. firstUpper()
    String.prototype.firstUpper = function() {
        return this.charAt(0).toUpperCase() + this.slice(1);
    };