optional-chain-expression-optional-expression.js 523 B

1234567891011121314151617181920
  1. // Copyright 2019 Google, Inc. All rights reserved.
  2. // This code is governed by the BSD license found in the LICENSE file.
  3. /*---
  4. esid: prod-OptionalExpression
  5. description: >
  6. optional chain bracket notation containing optional expresion
  7. info: |
  8. OptionalChain:
  9. ?. [OptionalExpression]
  10. features: [optional-chaining]
  11. ---*/
  12. const a = undefined;
  13. const b = {e: 0};
  14. const c = {};
  15. c[undefined] = 11;
  16. const d = [22];
  17. assert.sameValue(undefined, a?.[a?.b]);
  18. assert.sameValue(11, c?.[a?.b]);
  19. assert.sameValue(22, d?.[b?.e]);