Partitioning an array based on a condition in Javascript
Using TypeScript/ECMAScript 6 syntax it can be achieved this way. I am not sure whether it's more or less elegant compared to the original variant, but


It does the job;
Requires only one run;
Can be further chained with map () or other functions.




const [small, large] =                             // Use "deconstruction" style assignment
  [12, 5, 8, 130, 44]
    .reduce((result, element) =&gt; {
      result[element &lt;= 10 ? 0 : 1].push(element); // Determine and push to small/large arr
      return result;
    },
    [[], []]);                                     // Default small/large arrays are empty




More options can be found in various StackOverflow questions.