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 16let array = [1, 2]; 17array.push = function() { 18 print("123"); 19} 20array.push(); 21 22let string = "11" 23string += "22" 24print(string.slice()) 25print(string.length) 26 27let object = new Object(); 28print(object.toString()) 29 30function foo() { 31 var o = []; 32 for (let i = 0; i < 2; i++) { 33 o.push(foo) 34 } 35 print(o.length) 36} 37 38foo() 39 40let map = new Map() 41map.set("1", "2") 42print(map.get("1")) 43 44let set = new Set() 45set.add("1") 46set.add(23) 47set.add("c") 48for (const item of set) { 49 print(item); 50} 51 52let int8Array = new Int8Array(1); 53function foo2(a) { 54 new a.constructor(); 55} 56foo2(int8Array); 57 58