3 <script type=
"text/javascript">
6 var testArray
= new Array("Hello", "Hi", true, 5, 5, 9, null, undefined);
7 var testArray2
= new Array("Hello", "Hi", true, 5, 5, 9);
8 var testArray3
= new Object
;
9 testArray3
.__proto__
= testArray2
.__proto__
;
10 testArray3
[0] = "Hello";
16 testArray3
.length
= 6;
17 var testArray4
= [5, 5, 5, undefined];
19 var testArray5
= [5, 5, 5, undefined];
21 var testArray6
= new Array(20);
22 if (window
.testRunner
)
23 testRunner
.dumpAsText();
30 <p>1.0 Direct Testing, no starting at Parameter
<br>
31 * The indexOf String
"Hello" is
<script>document
.write(testArray
.indexOf("Hello"))</script><br>
32 * The indexOf String
"Hi" is
<script>document
.write(testArray
.indexOf("Hi"))</script><br>
33 * The indexOf Boolean 'true' is
<script>document
.write(testArray
.indexOf( true ))</script><br>
34 * The indexOf Number '
5' is
<script>document
.write(testArray
.indexOf( 5 ))</script><br>
35 * The indexOf Number '
9' is
<script>document
.write(testArray
.indexOf( 9 ))</script>
38 <p>2.0 A firstIndex parameter of
1 (positive offset test)
<br>
39 * The indexOf String
"Hi" is
<script>document
.write(testArray
.indexOf("Hi",1))</script><br>
40 * The indexOf Boolean 'true' is
<script>document
.write(testArray
.indexOf(true,1))</script><br>
41 * The indexOf Number
5 is
<script>document
.write(testArray
.indexOf(5,1))</script><br>
42 * The indexOf Number
9 is
<script>document
.write(testArray
.indexOf(9,1))</script>
45 <p>3.0 A firstIndex parameter of -
4 (negative offset test)
<br>
46 * The indexOf String
"Hi" is
<script>document
.write(testArray
.indexOf("Hi",-4))</script><br>
47 * The indexOf Boolean 'true' is
<script>document
.write(testArray
.indexOf(true,-4))</script><br>
48 * The indexOf Number
5 is
<script>document
.write(testArray
.indexOf(5,-4))</script><br>
49 * The indexOf Number
9 is
<script>document
.write(testArray
.indexOf(9,-4))</script>
52 <p>4.0 A big positive firstIndex of
1000, to test the firstIndex
> length
<br>
53 * The indexOf Number '
9' is
<script>document
.write(testArray
.indexOf(9,1000))</script>
56 <p>5.0 A big positive firstIndex of
4294967301, to test when firstIndex
> width of int (
32-bits)
<br>
57 * The indexOf Boolean 'true' is
<script>document
.write(testArray
.indexOf(true, 4294967301))</script>
60 <p>6.0 No arguments
<br>
61 * No arguments passed:
<script>document
.write(testArray
.indexOf())</script><br>
62 * No arguments passed:
<script>document
.write(testArray2
.indexOf())</script>
65 <p>7.0 Looking for null
<br>
66 * The indexOf null is
<script>document
.write(testArray
.indexOf(null))</script><br>
67 * The indexOf null is
<script>document
.write(testArray2
.indexOf(null))</script>
70 <p>8.0 Extra arguments
<br>
71 * The indexOf String
"Hello" is
<script>document
.write(testArray
.indexOf("Hello", 0, true))</script>
74 <p>9.0 NaN firstIndex
<br>
75 * The indexOf String
"Hi" is
<script>document
.write(testArray
.indexOf("Hello", "Hey"))</script>
78 <p>10.0 Small firstIndex
<br>
79 * The indexOf Boolean 'true' is
<script>document
.write(testArray
.indexOf(true, 0.45))</script>
82 <p>11.0 Negative firstIndex bigger than the length of the array
<br>
83 * The indexOf Boolean 'true' is
<script>document
.write(testArray
.indexOf(true, -1000))</script>
86 <p>12.0 Negative firstIndex bigger than
32-bits
<br>
87 * The indexOf Boolean 'true' is
<script>document
.write(testArray
.indexOf(true, -5294967301))</script>
90 <p>13.0 Looking for undefined
<br>
91 * The indexOf undefined is
<script>document
.write(testArray
.indexOf(undefined))</script><br>
92 * The indexOf undefined is
<script>document
.write(testArray2
.indexOf(undefined))</script><br>
93 * The indexOf undefined is
<script>document
.write(testArray4
.indexOf(undefined))</script><br>
94 * The indexOf undefined is
<script>document
.write(testArray5
.indexOf(undefined))</script><br>
95 * The indexOf undefined is
<script>document
.write(testArray6
.indexOf(undefined))</script>
98 <p>14.0 Object using the Array prototype
<br>
99 * The indexOf String
"Hello" is
<script>document
.write(testArray3
.indexOf("Hello"))</script><br>
100 * The indexOf String
"Hi" is
<script>document
.write(testArray3
.indexOf("Hi"))</script><br>
101 * The indexOf Boolean 'true' is
<script>document
.write(testArray3
.indexOf(true))</script><br>
102 * The indexOf Number '
5' is
<script>document
.write(testArray3
.indexOf(5))</script><br>
103 * The indexOf Number '
9' is
<script>document
.write(testArray3
.indexOf(9))</script>