Created
May 15, 2012 10:17
-
-
Save qmmr/2700610 to your computer and use it in GitHub Desktop.
JavaScript: extending native String with capitalize
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// adding capitalize method to String object | |
if (!String.prototype.capitalize) { | |
String.prototype.capitalize = function() { | |
return this.charAt(0).toUpperCase() + this.slice(1); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment