-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path6.9.html
More file actions
39 lines (35 loc) · 1.09 KB
/
Copy path6.9.html
File metadata and controls
39 lines (35 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>A future-proof JavaScript 1.6 forEach() method implementation</title>
<link rel="stylesheet" href="qunit/qunit-1.18.0.css">
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<script src="qunit/qunit-1.18.0.js"></script>
<script type="text/javascript">
QUnit.test(
"A future-proof JavaScript 1.6 forEach() method implementation",
function(assert)
{
if (!Array.prototype.forEach)
{
Array.prototype.forEach = function(callback, context)
{
for (var i = 0; i < this.length; i++)
{
callback.call(context || null, this[i], i, this);
}
};
}
["a", "b", "c"].forEach(function(value, index, array) {
assert.ok(value,
value + " is in position " + index + " out of " +
(array.length - 1));
})
});
</script>
</body>
</html>