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

Re: Forbids optional arguments ?

Expand Messages
  • Douglas Crockford
    ... Do not declare a name that is already declared. In this case, simply delete the word var . padchar = ;
    Message 1 of 3 , Jul 15, 2008
    • 0 Attachment
      --- In jslint_com@yahoogroups.com, "osteocosmosis" <fredistic@...> wrote:
      >
      > I 'redefine' padchar in the following. Is there a workaround?
      > Yes, I can copy it into another variable, but the code is actually okay
      > as it is.
      >
      > String.prototype.padleft = function(finalwidth, padchar) {
      > if (1 == arguments.length) {
      > var padchar = ' '; // false error jslint...
      > }
      > var len = this.length;
      > var s = this;
      > return (s.length < finalwidth) ?
      > (new Array(1 + finalwidth - len)).join(padchar) + s : s;
      > };

      Do not declare a name that is already declared. In this case, simply
      delete the word 'var'.

      padchar = ' ';
    • osteocosmosis
      Yes. Of course. Thanks.
      Message 2 of 3 , Jul 15, 2008
      • 0 Attachment
        Yes. Of course. Thanks.

        > Do not declare a name that is already declared...
      Your message has been successfully submitted and would be delivered to recipients shortly.