PAGE2GO2 HOME | INTERNET NEWS

LeighExchange - Free Advertising Network Stock Research at Internet Speed

Re: Request for Comments: StringUtils utility for JavaScript

 List
Subject: Re: Request for Comments: StringUtils utility for JavaScript
Poster: femto
Date: 23 Mar 2007 07:33:44 -0700
Related Postings: 1 2
Hi, Not very much comment, but here isBlank: function(str) { var i, // counter strLen; // the str length if((str == null) || (strLen = str.length)) { return true; }

I guess strLen = str.length is kind of buggy or weird, maybe str.length == 0?

in line 618: endsWidth: function(str, suffix) { return StringUtils.startsWith(str, str.length - suffix.length); }, should be return StringUtils.startsWith(str, suffix, str.length - suffix.length); ?

in line 686: for (i = 0; i < str1.length && i < str2.length; ++i) { if (str1.charAt(i) !== str2.charAt(i)) { break; } } if (i < str2.length || i < str1.length) { return i; } return -1;

don't get it, why doesn't for (i = 0; i < str1.length && i < str2.length; ++i) { if (str1.charAt(i) !== str2.charAt(i)) { return i; } } ?

many place use === , don't get it.

On Mar 23, 3:41 pm, Ray.Djajadin...@gmail.com wrote:
> Dear all,
>
> Well... basically I got sick of implementing the same thing over and
> over again for Strings. So I'm putting all the commonly used String
> operations in one file, which I've released as part of a (future)
> JavaScript library for common operations.
>
> The StringUtils can be viewed here:
>
> http://javascript-commons.googlecode.com/svn/trunk/javascript-commons...
>
> It's a very preliminary version. Tell me what you think--suggestions,
> criticisms, etc. are very welcome!
>
> Thanks,
> - RD

 

Page2Go2.com is not responsible for content of this message.