Sign in
webkit
/
WebKit
/
6ac1ae7345a9a50f3760d4fdf5f8c6512c4a9901
/
.
/
PerformanceTests
/
JetStream2
/
LuaJSFight
/
list_search.js
blob: 878a14bc757e5911ba044d0058facec6f09372f0 [
file
] [
log
] [
blame
]
function
firstWhere
(
list
,
fn
)
{
for
(
var
x of list
)
{
if
(
fn
(
x
))
{
return
x
;
}
}
return
null
;
}
nums
=
[
1
,
2
,
3
,
4
,
5
,
6
,
7
];
function
isEven
(
x
)
{
return
(
x
&
1
)
==
0
;
}
firstEven
=
firstWhere
(
nums
,
isEven
);
print
(
'First even: '
+
firstEven
)