Loading ...
Sorry, an error occurred while loading the content.

Re: Getting Crockford's 'supplant' past JSLint

Expand Messages
  • douglascrockford
    ... Thanks. I corrected that. My view on good JS style continues to evolve as I learn more about the language, thanks primarily to all of you who provide a
    Message 1 of 3 , Sep 21, 2012
    • 0 Attachment
      --- In jslint_com@yahoogroups.com, Martin Cooper <mfncooper@...> wrote:
      >
      > On Mr Crockford's Remedial JavaScript page:
      >
      > http://javascript.crockford.com/remedial.html
      >
      > near the bottom, there is a little function called 'supplant' that
      > looks like this:
      >
      > if (!String.prototype.supplant) {
      > String.prototype.supplant = function (o) {
      > return this.replace(/{([^{}]*)}/g,
      > function (a, b) {
      > var r = o[b];
      > return typeof r === 'string' || typeof r === 'number' ? r : a;
      > }
      > );
      > };
      > }
      >
      > The problem is, I cannot find a way to get JSLint to allow me to use
      > this code. No matter what options I choose, I get:
      >
      > Unescaped '{'.
      > return this.replace(/{([^{}]*)}/g,
      > Unescaped '}'.
      > return this.replace(/{([^{}]*)}/g,
      >
      > So how do I turn these warnings off? It seems odd that I can't get Mr
      > Crockford's own code to pass muster in JSLint.


      Thanks. I corrected that.

      My view on good JS style continues to evolve as I learn more about the language, thanks primarily to all of you who provide a constant stream of examples of how susceptible this language is to easily avoidable errors. I try to keep my code up to snuff. I missed this nugget buried in an old html file.
    Your message has been successfully submitted and would be delivered to recipients shortly.