forked from chakra-core/ChakraCore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray_every.js
More file actions
53 lines (41 loc) · 1.32 KB
/
array_every.js
File metadata and controls
53 lines (41 loc) · 1.32 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
function returnTrue(x,y,z)
{
WScript.Echo("value:"+ x + " index:" + y + " Object:" + z);
return true;
}
function returnFalse(x,y,z)
{
WScript.Echo("value:"+ x + " index:" + y + " Object:" + z);
return false;
}
function returnRandom(x,y,z)
{
WScript.Echo("value:"+ x + " index:" + y + " Object:" + z);
return y!=1;
}
Array.prototype[6] = 20;
var x = [1,2,3,4,5];
var y = x.every(returnTrue,this);
WScript.Echo(y);
x = [10,20,30,40,50];
y = x.every(returnFalse, this);
WScript.Echo(y);
x = [10,20,30,40,50];
y = x.every(returnRandom, this);
WScript.Echo(y);
x = {0: "abc", 1: "def", 2: "xyz"}
x.length = 3;
y = Array.prototype.every.call(x, returnTrue,this);
WScript.Echo(y);
y = Array.prototype.every.call(x, returnFalse,this);
WScript.Echo(y);
y = Array.prototype.every.call(x, returnRandom, this);
WScript.Echo(y);
x = [10,20,30,40,50];
x[8] = 10;
y = x.every(returnTrue, this);
WScript.Echo(y);