Estimated time: 10 minutes
This file contains 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
/** | |
* Description: Count a string (mixing English and Chinese characters) length. | |
* A basic and rough function. | |
* | |
* Performance: | |
* Multiple methods performance test on http://jsperf.com/count-string-length. | |
* You can see that using regexp to check range is very slow from the above test page. | |
*/ | |
function strLen(str) { | |
var count = 0; |