Some remark:
Replace:
.replace(from, to) - 65ms
.split(from).join(to) - 200ms
array creating is not very fast.
Work with comma separated value:
var a = b.split(','); for(var i = 0; i < a.length; i++){} - 147ms
b.replace(/[^,]+/g, function(s){}) - 235ms
But lambda expression is even worse.
Replace for the first occurrence
.replace(/s/, '') - 29ms
.replace('s', '') - 34ms
Maybe because every time called toString
Substring:
.slice - 28ms
.substr - 30ms
slice seems as better choice for string reduction.
Trim:
.replace(/^\s+|\s+$/g, '') - 64ms
.replace(/^\s+/, '').replace(/\s+$/, '') - 82ms
Get symbol from string
str[1] - 14ms
str.charAt(1) - 16ms
...


LinkBack URL
About LinkBacks



Reply With Quote
