Here you can find the source of capitalize()
// Capitalize first letter. String.prototype.capitalize = function () { return this.charAt(0).toUpperCase() + this.slice(1); }
String.prototype.capitalize = function() { return this.replace(/(?:^|\s)\S/g, function(a) { return a.toUpperCase(); }); };
String.prototype.capitalize = function() { return this[0].toUpperCase() + this.slice(1);
String.prototype.capitalize = function () { return this.charAt(0).toUpperCase() + this.slice(1).toLowerCase();
String.prototype.capitalize = function() { return this.slice(0, 1).toUpperCase() + this.slice(1).toLowerCase(); };
String.prototype.capitalize = function () { 'use strict'; return this.charAt(0).toUpperCase() + this.slice(1); };
String.prototype.capitalize = function () { return this.charAt(0).toUpperCase() + this.slice(1);
String.prototype.capitalize = function () { return this ? this.charAt(0).toUpperCase() + this.slice(1) : ''; };
String.prototype.capitalize = function() { var str = this return str.charAt(0).toUpperCase() + str.slice(1);
String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase(); };