Details
-
Suggestion
-
Resolution: Fixed
-
P4: Low
-
1.9.1
-
None
-
087c22e17 (master)
Description
Qbs JavaScript engine supports methods such as some (check that some element matches the predicate), forEach (execute predicate for each element), every (check that all elements matches the predicate) etc. It does not support ECMAScript 2015 addition of `find` (return first element that matches the predicate). As per JavaScript documentation the workaround to define it ourselves and they even provide the implementation. However it would be nice if it was part of the engine as I believe it is quite useful and considerably shortens the code as otherwise one has to iterate over the array, check the value and return the element or break from the loop:
var value; var array = [1,2,3,4,5]; for(var i in array) { if(array[i] == 3) { value = array[i]; break; } }
vs
var value = [1,2,3,4,5].find(function(element) { return element == 3; });