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

Strict white space bug?

Expand Messages
  • spence.randall@ymail.com
    Given the following code (view with fixed width): var tester = (function () { var names = Alex,Brandon,Carl + Don,Edward,Frank,Gale +
    Message 1 of 6 , Apr 28, 2011
    • 0 Attachment
      Given the following code (view with fixed width):

      var tester = (function () {
      var names = 'Alex,Brandon,Carl' +
      'Don,Edward,Frank,Gale' +
      'Hank,Ian,Jack,Ken,Leo'.split(','),
      other = function (test) {
      var string = '';
      return string + test;
      };
      return {
      names: names,
      other: other
      };
      }());

      JSLint reports Error:

      Problem at line 6 character 13: Expected 'var' at column 17, not column 13.
      Problem at line 7 character 13: Expected 'return' at column 17, not column 13.
      Problem at line 8 character 9: Expected '}' at column 13, not column 9.

      Change the code to this:

      var tester = (function () {
      var names = 'Alex,Brandon,Carl,Don,Edward,Frank,Gale,Hank,Ian,Jack,Ken,Leo'.split(','),
      other = function (test) {
      var string = '';
      return string + test;
      };
      return {
      names: names,
      other: other
      };
      }());

      And it doesn't produce an error.
    • Douglas Crockford
      Thanks for pointing out those two problems. Please try it now.
      Message 2 of 6 , Apr 28, 2011
      • 0 Attachment
        Thanks for pointing out those two problems. Please try it now.
      Your message has been successfully submitted and would be delivered to recipients shortly.