# Copyright (c) 2021 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. 10 1,1,0,0,1,1 100 ,,0,0, 5 1,2,3,4,5 4 1,2,3,4 4 1,2,3,3 5 2,3,4,5,6 5,4,3,2,1 10 undefined undefined undefined 8 undefined 9 0 9 2 1 undefined 9 2 undefined 1 9 10 1 2 3 4 5 undefined undefined undefined undefined undefined 9 10 undefined undefined undefined undefined undefined undefined undefined 1 2 3 16 6 -1 The NewTarget is undefined undefined 1 6 6 undefined 2 2 6,,4,3,2,1 1,2,3,4,,6 1,2,6,4,5 1,2,3,4,5 Dec,Feb,Jan,Mar Mar,Jan,Feb,Dec 1,2,10,21 1,10,21,2 5,4,3,2,,0 ======== Begin: Array.prototype.reverse() ======== arr0.reverse() === arr0 ? true arr0.length after reverse() called = 0 arr1.reverse() === arr1 ? true arr1 after reverse() called = 1 arrWithHoles before reverse() called = ,1,,,4,,,,, arrWithHoles.reverse() = ,,,,,4,,,1, arrWithHoles after reverse() called = ,,,,,4,,,1, ======== End: Array.prototype.reverse() ======== ======== Begin: Array.prototype.indexOf() & Array.prototype.lastIndexOf() ======== arr = [0, 10, 20, 80, 40, Hole, undefined, 10, "80", Hole] Group 1: 0 <= fromIndex < arr.length: 4,-1,1,7,4,-1,7,1 Group 2: -arr.length <= fromIndex < 0: -1,4,7,1,4,-1,1,-1,0,1,0,-1 Group 3: fromIndex >= arr.length: -1,-1,-1,-1,0,0 Group 4: fromIndex < -arr.length: 0,-1 Group 5: fromIndex in [Infinity, -Infinity]: 1,-1,-1,7 Group 6: fromIndex is NaN: 0,1,0,-1 Group 7: fromIndex is not of type 'number': 7,1,7,7 Group 8: Strict equality checking: 8,3 Group 9: Searching undefined and null: 6,6,-1,6,6,-1 Group 10: fromIndex with side effects: - indexOf: result = -1, accessCount = 6 - lastIndexOf: result = -1, accesscount = 6 Group 11: fromIndex that triggers exceptions: Expected TypeError caught in indexOf when fromIndex is bigint. Expected TypeError caught in lastIndexOf when fromIndex is bigint. Expected TypeError caught in indexOf when fromIndex is symbol. Expected TypeError caught in lastIndexOf when fromIndex is symbol. ======== End: Array.prototype.indexOf() & Array.prototype.lastIndexOf() ======== CallbackFn is not callable ,,baz ,,baz {"0":-1.6304390272817058e+308,"length":1} constructor get [Symbol.species] constructor 1 1 0 0 constructor get [Symbol.species] constructor 1 1 0 0 constructor get [Symbol.species] constructor 1 1 0 0 constructor get [Symbol.species] constructor 1 1 0 0 constructor constructor constructor n 100 0 false false false 3000 true 10,10,10,10,10,10,10,10,10,10 3,4,5,6,4,5,6,7,8,9 3,4,5,6,4,5,6,7,8,9 0,1,,3,4,5,6,7,8,9 0,1,2,0,1,2,3,4,5,9 5,6,2,3,4,5,6,7,8,9 5,6,2,3,4,5,6,7,8,9 true true true true 145 145 109 125 false false true 15 13 [object Object] Dec,Feb,Jan,Mar Dec,Feb,Jan,Mar 1 TypeError TypeError TypeError TypeError TypeError TypeError TypeError 1,2,3 apple,banana,orange true,false,true [object Object],[object Object] NaN,NaN,NaN Infinity,-Infinity /pattern1/,/pattern2/ [object Map],[object Map] [object Set],[object Set] 1,2,3,4,5,6 ark_unicodeValue 😀,ark_unicodeValue 😎 undefined Exception usage, but does not throw an error Caught an error: RangeError: Invalid array length 1,2,3 apple,banana,orange true,false,true [object Object],[object Object] NaN,NaN,NaN Infinity,-Infinity /pattern1/,/pattern2/ [object Map],[object Map] [object Set],[object Set] 1,2,3,4,5,6 ark_unicodeValue 😀,ark_unicodeValue 😎 Caught an error: TypeError: the mapfn is not callable. Caught an error: Error: Something went wrong Exception usage, but does not throw an error true true true true true true true true true true true false false false false false apple,banana,orange 1,2,3,4,5,6,7,8,9,10 apple,banana,orange [object Object],[object Object] ark_unicodeValue 😀,ark_unicodeValue 😎 1,2,3,4,5,6 1,2,3 undefined 1,2,3 1,2,3 1,2,3 Concatenated Array: 1,two,true,,,[object Object] Nested Concatenated Array: 1,two,true,1,2,a,b,true,false,,,[object Object] Mixed Concatenated Array: 1,two,true,4,five,[object Object] Spread Concatenated Array: 1,two,true,,,[object Object] Original Arrays: 1,2,3,apple,banana,orange,true,false,true,[object Object],[object Object],NaN,NaN,NaN,Infinity,-Infinity,/pattern1/,/pattern2/,[object Map],[object Map],[object Set],[object Set],1,2,3,4,5,6,ark_unicodeValue 😀,ark_unicodeValue 😎 Copied Array 1: 3,2,3 Copied Array 2: apple,apple,banana Copied Array 3: true,false,true Copied Array 4: [object Object],[object Object] Copied Array 5: NaN,NaN,NaN Index: 0 Value: 1,2,3 Index: 1 Value: apple,banana,orange Index: 2 Value: true,false,true Index: 3 Value: [object Object],[object Object] Index: 4 Value: NaN,NaN,NaN Index: 5 Value: Infinity,-Infinity Index: 6 Value: /pattern1/,/pattern2/ Index: 7 Value: [object Map],[object Map] Index: 8 Value: [object Set],[object Set] Index: 9 Value: 1,2,3,4,5,6 Index: 10 Value: ark_unicodeValue 😀,ark_unicodeValue 😎 true false true true false true Caught an error: TypeError: the callbackfun is not callable. Caught an error: ReferenceError: undefinedVariable is not defined 0,0,0,0,0 1,2,0,0,0 1,0,0,4,5 0,0,0,0,0 1,2,0,0,0 1,0,0,4,5 hello,hello,hello,hello,hello 1,0,0 1,0,3 2,4 3,4,5 1,2,3,4,5 3 apple,banana,orange [object Object],[object Object] Caught an error: TypeError: the callbackfun is not callable. Caught an error: TypeError: is not callable undefined undefined 6 undefined null 1,2,3 6 null undefined NaN false Caught an error: TypeError: the predicate is not callable. Caught an error: TypeError: the predicate is not callable. Caught an error: TypeError: Cannot read property find of null Caught an error: ReferenceError: array is not defined -1 -1 0 -1 8 7 11 0 7 6 5 9 Caught an error: TypeError: the predicate is not callable. Caught an error: TypeError: the predicate is not callable. Caught an error: TypeError: Cannot read property findIndex of null Caught an error: ReferenceError: array is not defined undefined undefined 10 undefined 1,2,3 1,2,3 1,2,3 null undefined 1,2,3 false Caught an error: TypeError: the predicate is not callable. Caught an error: TypeError: the predicate is not callable. Caught an error: TypeError: Cannot read property findLast of null Caught an error: ReferenceError: array is not defined -1 -1 4 -1 8 11 11 11 7 6 11 9 Caught an error: TypeError: the predicate is not callable. Caught an error: TypeError: the predicate is not callable. Caught an error: TypeError: Cannot read property findLastIndex of null Caught an error: ReferenceError: array is not defined 1,2,3,4,5,6,7,8,9,10 1,2,3,4,5,6,7,8,9,10 1,2,3,4,5 1,2,,3, 1,2,3,4,5,6 1,2,3,4,5 1,string,[object Object],, 1,NaN,Infinity,2,3,NaN 1,2,3,4 1,2,3,4 1,2,2,4,3,6 2,4,6 1,0,2,1,3,2 1,2,3 1,2,3,4,5,6 1,2,3,4 1,2,4,3 1 2 3 apple banana orange true false true [object Object] [object Object] NaN NaN NaN Infinity -Infinity /pattern1/ /pattern2/ [object Map] [object Map] [object Set] [object Set] 1,2,3 4,5,6 ark_unicodeValue 😀 ark_unicodeValue 😎 Caught an error: TypeError: the callbackfun is not callable. Array: [1, 2, 3, 4, 5], Target: 3, Result: true Array: [1, 2, 3, 4, 5], Target: 6, Result: false Array: [NaN, 2, 3], Target: NaN, Result: true Array: [, 2, 3], Target: undefined, Result: true Array: [apple, banana, orange], Target: banana, Result: true Array: [apple, banana, orange], Target: grape, Result: false Array: [], Target: 1, Result: false Array: [true, false, true], Target: true, Result: true Array: [true, false, true], Target: false, Result: true Array: [Infinity, -Infinity], Target: Infinity, Result: true Array: [Infinity, -Infinity], Target: -Infinity, Result: true Array: [[object Map], [object Map]], Target: [object Map], Result: false Array: [[object Set], [object Set]], Target: [object Set], Result: false 2 0 4 -1 1 1 -1 -1 1 -1 apple,banana,cherry apple, banana, cherry apple apple,1,[object Object] apple + banana + cherry 0 1 2 true 0 true 0 1 0 1 2 4 0 5 -1 -1 -1 2 2,4,6,8,10 2,4,NaN,8,NaN 2,,6 1,2,3 2,4,6,8,10,12 5 1,2,3,4 undefined 1 apple 1,2,3,4 1,2,3,4,5,6 1 [object Object],[object Object] 1,2,3,4 1,2,3, 1,2 15 0 1 NaN edcba initialValue a dundefinedba e,d,c,b,a a d,,b,a a b,c,d,e undefined a a ,b,c b,c a ,b true false false true true 1,1,2,3,4,5,5,6,9 1 1,3,5, apple,banana,cherry c,d a,b,x,y,e x,y a x,y ,3 1,5 apple,banana,cherry 1,2,3,4,5 1,two,true 5 x,y,a,b,c 2 x,y 2 x,a 4 x,1,2, 7 5,6,7,1,2,,4 8 5,6,7,8,1,2,,4 e,d,c,b,a a d,,b,a 1,1,2,3,4,5,5,6,9 1 1,3,5, apple,banana,cherry a,b,x,y,e a,b,c,d,e x,y x,y a 1,5 1,,3,5 true true true true true true false false false false false false false false false false true