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 */ 15 16import assert from 'assert'; 17 18function foo() { 19 return { Propx1: 1, Propy1: 2 }; 20} 21 22const { Propx1, Propy1 } = foo(); 23assert(Propx1 === 1, 'success'); 24assert(Propy1 === 2, 'success'); 25 26// let Propx2 =3; 27// let Propy3 =4; 28// let Propy4 =5; 29const { Propx2, Obj: {Propy3, Propy4} } = {Propx2:2, Obj: {Propy3:3, Propy4:4}} 30assert(Propx2 === 2, 'success'); 31assert(Propy3 === 3, 'success'); 32assert(Propy4 === 4, 'success'); 33 34 35const {...rest1} = {prop1: 1, prop2: 2}; 36assert(rest1.prop1 === 1, 'success'); 37assert(rest1.prop2 === 2, 'success'); 38 39const { prop3, ...rest2} = {prop3: 3, prop4: 4}; 40assert(prop3 === 3, 'success'); 41assert(rest2.prop4 === 4, 'success'); 42 43let name11 = 'hello'; 44let info = {name11};