Kwebble : Blog

Archief van 25 juni 2010

  • A trim() method for the JavaScript String class

    Gepubliceerd op 25 juni 2010 in Programming.

    Just rediscovered that IE still doesn’t include the trim() method on the String class. Here’s a snippet of code, based on an answer on StackOverflow, to make sure there’s a trim method available:

    if (typeof String.prototype.trim !== 'function') {
        String.prototype.trim = function() {
            return this.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
        }
    }
    

    On the positive side I also found out about the debugger included in IE 8. Just like Firebug, available via F12!

    • javascript
  • Rubrieken

    • Artikelen
    • Foto's
    • Links
    • Media
    • Overheid
    • Programming
  • Recente Berichten

    • Stanford Web Applications course lectures
    • The importance of knowing Unicode
    • “If you are not paying for it, you’re not the customer; you’re the product being sold.”
    • Inzage in je gegevens bij Facebook
    • Tuning Oracle UCM 11 & Site Studio performance
  • Abonneren

    • Atom feed Artikelen
    • Atom feed Reacties
  • Archief

© Rob Schlüter - Contact