Nodejs String to Upper Case toUpperCaseFirstLetter()

Here you can find the source of toUpperCaseFirstLetter()

Method Source Code

window.upperCaseFirstLetter = (str)=>{
   return str.replace(/^\w/, function(w){return w.toUpperCase()});
}
String.prototype.toUpperCaseFirstLetter = function(){
   return upperCaseFirstLetter(this);
}

Related

  1. toUpper()
    String.prototype.toUpper = function() {
      return this.replace(/[a-z]/g, function(x) {
        return String.fromCharCode(x.charCodeAt(0) - 32);
      });
    
  2. toUpperCase()
    String.prototype.toUpperCase = function() {
      var s = "";
      for (var i = 0, len = this.length; i < len; i++) {
        var char = this.charCodeAt(i);
        if (char >= 97 && char <= 122) {
          s += String.fromCharCode(char - 32);
        } else {
          s += this[i];
      return s;
    };
    
  3. toUpperCaseFirst()
    String.prototype.toUpperCaseFirst = function() {
        return this.charAt(0).toUpperCase() + this.slice(1);
    };
    
  4. toUpperCaseFirst()
    String.prototype.toUpperCaseFirst = function() {
        return this[0].toUpperCase() + this.substr(1);
    };
    
  5. toUpperCaseFirst()
    String.prototype.toUpperCaseFirst = function() {
      return this.slice(0,1).toUpperCase() + this.slice(1).toLowerCase();
    };
    
  6. toUpperLowerCase()
    String.prototype.toUpperLowerCase = function() {
        var string = this.split("");
        string[0] = string[0].toUpperCase();
        return string.join("");
    };
    
  7. toUpperLowerCase()
    String.prototype.toUpperLowerCase = function() {
        var string = this.split("");
        string[0] = string[0].toUpperCase();
        return string.join("");
    };
    String.prototype.firstUpper = function() {
        return this.charAt(0).toUpperCase() + this.slice(1);
    };
    
  8. ucWords()
    String.prototype.ucWords = function () {
        return this.split(' ').map(function (w) {
            return w.substr(0, 1).toUpperCase() + w.substr(1); 
        }).join(' ');
    
  9. uc_words()
    String.prototype.uc_words = function(){
        return this.replace( /(^|\s)([a-z])/g , function(m,p1,p2){return p1+p2.toUpperCase();});
    };