smallObjectVariableKeyHasProp-2.js (507B)
1 let obj = { 2 a: 1, 3 b: 1, 4 c: 1, 5 }; 6 7 function test(id) { 8 return Object.hasOwn(obj, id); 9 } 10 11 let testKeys = [ 12 ["a", true], 13 ["b", true], 14 ["c", true], 15 ["d", false], 16 ["e", false], 17 ["f", false], 18 ["g", false], 19 ["h", false], 20 ]; 21 22 with({}); 23 for (var i = 0; i < 1000; i++) { 24 let [key, has] = testKeys[i % testKeys.length]; 25 test(key); 26 } 27 28 obj["0"] = 1; 29 testKeys.push(["0", true]); 30 31 for (var i = 0; i < 1000; i++) { 32 let [key, has] = testKeys[i % testKeys.length]; 33 assertEq(test(key), has); 34 }