Nodejs String Capitalize capitalize()

Here you can find the source of capitalize()

Method Source Code

// Copyright 2000 - 2015 NeuStar, Inc.All rights reserved.
///*  ww w .jav a  2 s  .  c om*/
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
String.prototype.capitalize = function() {
  return this.charAt(0).toUpperCase() + this.slice(1);
};

String.prototype.doubleQuote = function() {
  return '"' + this + '"';
};

Related

  1. capitalize()
    String.prototype.capitalize = function () {
      return this[0].toUpperCase() + this.slice(1);
    };
    
  2. capitalize()
    String.prototype.capitalize = function () {
        if (this.valueOf()) {
            var novoTexto = "", palavra, palavras = this.valueOf().split(" ");
            for (var i = 0; i < palavras.length; i++) {
                palavra = palavras[i];
                novoTexto += palavra.substr(0, 1).toUpperCase() + palavra.substr(1) + " ";
            return novoTexto.trim();
        return "";
    
  3. capitalize()
    String.prototype.capitalize = function() {
        return this.charAt(0).toUpperCase() + this.slice(1);
    function mapRange(value, low1, high1, low2, high2){
        return low2 + (high2 - low2) * ((value - low1) / (high1 - low1));
    function getAssocSize(array){
        var size = 0, key;
        for (key in array) {
    ...
    
  4. capitalize()
    String.prototype.capitalize = function() {
        return this.charAt(0).toUpperCase() + this.slice(1);
    
  5. capitalize()
    String.prototype.capitalize = function() {
      return this.charAt(0).toUpperCase() + this.substr(1);
    };
    
  6. capitalize()
    String.prototype.capitalize = function() {
        return this.charAt(0).toUpperCase() + this.slice(1);
    
  7. capitalize()
    String.prototype.capitalize = function() {
       return this.charAt(0).toUpperCase() + this.slice(1);
    String.prototype.titleize = function() {
       var string_array = this.split(' ');
       string_array = string_array.map(function(str) {
          return str.capitalize();
       });
       return string_array.join(' ');
    ...
    
  8. capitalize()
    String.prototype.capitalize = function(){
      var val = this;
      return val[0].toUpperCase() + val.substring(1);
    
  9. capitalize()
    String.prototype.capitalize = function(){ 
        return this.replace(/\w+/g, function(a){
            return a.charAt(0).toUpperCase() + a.substr(1).toLowerCase();
        });
    };