blob: 0dbc0dca5e02d0623c2d9da0507512f4be4176a8 [file] [log] [blame]
<html>
<head>
<script type="text/javascript">
function print(str) {
document.writeln(str+"<br/>");
}
if (window.testRunner)
testRunner.dumpAsText();
</script>
</head>
<body>
1.0 Behavior with Holes in Array<br/>
The following tests ensure that map skips holes in the array it constructs. You should see false and true printed in that order, followed by the printing of the indexes and values in two arrays, the first of which has no indexes and the second of which has one, whose value is NaN:<br/><br/>
<script>
function twice(element, index, array) {
return 2 * element;
}
var arr = [1, 2, 3, 4];
delete arr[2];
var res = arr.map(twice);
print(2 in res);
print(res[0] == 2 && res[1] == 4 && res[3] == 8);
arr = new Array(20);
res = arr.map(twice);
print("The following indexes are in the result array:");
for (var i in res)
print(i + ": " + res[i]);
print("End indexes in the result array.");
arr[15] = undefined;
res = arr.map(twice);
print("The following indexes are in the result array:");
for (var i in res)
print(i + ": " + res[i]);
print("End indexes in the result array.");
</script>
</body>
</html>