Debian Codegraph @

js/src/tests/test262/language/expressions/optional-chaining/short-circuiting.js

raw
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 demonstrate syntax-based short-circuiting.
7 info: |
8 If the expression on the LHS of ?. evaluates to null/undefined, the RHS is
9 not evaluated
10 features: [optional-chaining]
11 ---*/
12
13 const a = undefined;
14 let x = 1;
15
16 a?.[++x] // short-circuiting.
17 a?.b.c(++x).d; // long short-circuiting.
18
19 undefined?.[++x] // short-circuiting.
20 undefined?.b.c(++x).d; // long short-circuiting.
21
22 assert.sameValue(1, x);
23
24 reportCompare(0, 0);