Debian Codegraph @

js/src/tests/test262/language/expressions/optional-chaining/optional-chain-prod-arguments.js

raw
1 // Copyright 2020 Salesforce.com, 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 Productions for ?. Arguments
7 info: |
8 OptionalChain[Yield, Await]:
9 ?. Arguments
10 features: [optional-chaining]
11 ---*/
12
13 function fn(arg1, arg2, arg3 = 0) {
14 return arg1 + arg2 + arg3;
15 }
16
17 assert.sameValue(fn?.(10, 20), 30, 'regular');
18 assert.sameValue(String?.(42), '42', 'built-in');
19 assert.sameValue(fn ?. (...[10, 20, 40]), 70, 'spread');
20
21 reportCompare(0, 0);