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

1406array destructuring

Expand Messages
  • Mark Volkmann
    Aug 2, 2010
    • 0 Attachment
      Just learned something new! This works in Rhino 1.7. See the line with
      the comment below.

      function assert(condition) {
      if (!condition) print('assertion failed'));
      }

      function getValues() {
      return ['text', 19, true];
      }

      var [s, n, b] = getValues(); // Array destructuring!

      assert(s === 'text');
      assert(n === 19);
      assert(b);

      I can't find this in the ECMAScript 3 spec. Is this a standard
      JavaScript feature?

      --
      R. Mark Volkmann
      Object Computing, Inc.
    • Show all 6 messages in this topic