Posted By

nivlam on 12/30/09


Tagged


Versions (?)

Javascript Trim


 / Published in: JavaScript
 

URL: http://blog.stevenlevithan.com/archives/faster-trim-javascript

  1. function trim12 (str) {
  2. var str = str.replace(/^\s\s*/, ''),
  3. ws = /\s/,
  4. i = str.length;
  5. while (ws.test(str.charAt(--i)));
  6. return str.slice(0, i + 1);
  7. }

Report this snippet  

You need to login to post a comment.