diff --git a/features.txt b/features.txt index 29cd28d..6ad4103 100644 --- a/features.txt +++ b/features.txt @@ -1404,7 +1404,7 @@ New function for finding an element in an array. 6| [ 1, 3, 4, 2 ].|findIndex|(|x =>| x > 3); // 2 5| [ 1, 3, 4, 2 ].|filter|(|function (x) { return| x > 3; })|[0]|; // 4 -5| // no equivalent in ES5 +5| [ 1, 3, 4, 2 ].|map|(|function(x, index) { return| x > 3 |? index : undefined; }).filter(function (x) { return x !== undefined; }|)|[0]|; // 2 String Repeating ---------------- diff --git a/index.html b/index.html index 00fcf5f..7450b38 100644 --- a/index.html +++ b/index.html @@ -1918,8 +1918,8 @@
ECMAScript 5 — syntactic sugar: reduced | traditional
-
[ 1, 3, 4, 2 ].filter(function (x) { return x > 3; })[0]; // 4 -// no equivalent in ES5
+
[ 1, 3, 4, 2 ].filter(function (x) { return x > 3; })[0]; // 4 +[ 1, 3, 4, 2 ].map(function(x, index) { return x > 3 ? index : undefined; }).filter(function (x) { return x !== undefined; })[0]; // 2