1/* 2 * Copyright (c) 2025 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 16var A = {a:1, b:2}; 17print('a' in A); 18print('b' in A); 19print('c' in A); 20 21let key1 = { 22 toString: function() { 23 return "3"; 24 } 25} 26 27let key2 = { 28 valueOf: function() { 29 return "4"; 30 }, 31 toString: null 32} 33 34let obj = {1: 1, "abc": 2, [key1]: 3, [key2]: 4}; 35 36let obj2 = {"5": 5}; 37obj.__proto__ = obj2; 38 39print(1 in obj) 40print("abc" in obj) 41print("3" in obj) 42print(5 in obj) 43print(6 in obj) 44print([key1] in obj) 45print([key2] in obj) 46 47let obj3 = {"abcdef": "abcdef"}; 48print("ab" + "cd" + "ef" in obj3); 49 50var str = new String("hello world"); 51print('1' in str); 52print('11' in str);