Search

What the Quote?

"Take that, fluff butt."

Mike Nickolai

"If I were the chicken-giver-outer, you'd be covered in poultry."

Steven Rodgers

"You just said, 'I please myself, donkey'."

Laura Tripcony

« LotusScript Replace a memory hog? | Main| Update: Javascript String.toProperCase »

Javascript String.toProperCase

Category show-n-tell thursday
While tinkering some more with XIDED tonight, I noticed that the lowercase theme (thanks to DXL lowercasing all tag names) was bugging me. Since I'm using Prototype anyway, I decided to extend the String object with a .toProperCase() function:

Object.extend(String.prototype, {
    toProperCase: function() {
        return this.slice(0,1).toUpperCase() + this.slice(1,this.length).toLowerCase();
    }
});

Pretty primitive, but for most of the data I want propercased it does the trick, because most of what I want propercased so far is only one word (Options, Declarations, Initialize, Terminate, etc.)... but I suspect I'll revisit it at some point to uppercase the first character following each of a few delimiters (space, pipe, backslash, and so forth).

By the way, sorry my SnTT's haven't actually been on Thursdays lately. My day planner's been in a box ever since the move, so the days all sort of blend together now.

Contact Me

Elsewhere

Assorted Linkage


Locations of visitors to this page