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

Numeric key names

Expand Messages
  • kaichen67
    Are numeric key names in objects no longer supported? with var modes = { 0: {cu: foo , fr: bar , txt: Text 0 }, 3: {cu: bar , fr: foo , txt: Text 3 }, 2:
    Message 1 of 2 , Jun 16, 2011
    • 0 Attachment
      Are numeric key names in objects no longer supported?

      with

      var modes = {
      0: {cu: 'foo', fr: 'bar', txt: 'Text 0'},
      3: {cu: 'bar', fr: 'foo', txt: 'Text 3'},
      2: {cu: 'bar', fr: 'foo', txt: 'Text 2'},
      8: {cu: 'foo', fr: 'bar', txt: 'Text 8'},
      4: {cu: 'baz', fr: 'bar', txt: 'Text 4'},
      9: {cu: 'baz', fr: 'foo', txt: 'Text 9'}
      };

      I get

      Error:
      Problem at line 3 character 45: Duplicate '(number)'.
      3: {su: 'bar', fr: 'foo', txt: 'Text 3'},
      Problem at line 4 character 45: Duplicate '(number)'.
      2: {su: 'bar', fr: 'foo', txt: 'Text 2'},
      Problem at line 5 character 45: Duplicate '(number)'.
      8: {su: 'foo', fr: 'bar', txt: 'Text 8'},
      Problem at line 6 character 45: Duplicate '(number)'.
      4: {su: 'baz', fr: 'bar', txt: 'Text 4'},
      Problem at line 8 character 1: Duplicate '(number)'.
      };

      never had probs before.

      var modes = {
      '0': {cu: 'foo', fr: 'bar', tx: 'Text 0'},
      '3': {cu: 'bar', fr: 'foo', tx: 'Text 3'},
      '2': {cu: 'bar', fr: 'foo', tx: 'Text 2'},
      '8': {cu: 'foo', fr: 'bar', tx: 'Text 8'},
      '4': {cu: 'baz', fr: 'bar', tx: 'Text 4'},
      '9': {cu: 'baz', fr: 'foo', tx: 'Text 9'}
      };

      works but I'd have to change some code.
    • Douglas Crockford
      ... Thanks. Please try it now.
      Message 2 of 2 , Jun 16, 2011
      • 0 Attachment
        --- In jslint_com@yahoogroups.com, "kaichen67" <kaichen67@...> wrote:

        > Are numeric key names in objects no longer supported?

        Thanks. Please try it now.
      Your message has been successfully submitted and would be delivered to recipients shortly.