• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15import y1 from 'assert';
16// 不新增变量
17let [z1, a2] = ['akria', 12];
18let { ...b2 } = { 'name2': 'akria2', age2: 18 };
19y1(z1 === 'akria', 'success');
20y1(a2 === 12, 'success');
21y1(b2.name2 === 'akria2', 'success');
22y1(b2.age2 === 18, 'success');
23function w1() {
24    let [k2, l2] = ['akria3', 13];
25    let { ...m2 } = { 'name2': 'akria4', age2: 18 };
26    y1(k2 === 'akria3', 'success');
27    y1(l2 === 13, 'success');
28    y1(m2.name2 === 'akria4', 'success');
29    y1(m2.age2 === 18, 'success');
30}
31w1();
32// 新增变量
33let { newName: c2, ...d2 } = { 'newName': 'akria5', newAge: 18 };
34y1(c2 === 'akria5', 'success');
35y1(d2.newAge === 18, 'success');
36function x1() {
37    return { Propx1: 1, Propy1: 2 };
38}
39const { Propx1: e2, Propy1: f2 } = x1();
40y1(e2 === 1, 'success');
41y1(f2 === 2, 'success');
42let g2 = 3;
43let h2 = 4;
44const { Propx2: i2, Propy2: j2 } = { Propx2: g2, Propy2: h2 };
45y1(i2 === 3, 'success');
46y1(j2 === 4, 'success');
47