Javascript Trim


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  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. }

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.