Friday, October 16, 2009

efficency string operation

Because string is immutable in JavaScript, concatenation with array.join('') is much efficient. The following code use all the chinese characters. Click here to show

var sb = []; sb[sb.length] = "<p>"; for (var i = 0x4e00; i <= 0x9fcf; i++) { sb[sb.length] = String.fromCharCode(i); } sb[sb.length] = "</p>"; $("#chinese").html(sb.join("")); return false;

No comments:

Post a Comment