Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/117.0
Firefox 117
Windows
Desktop
one year ago
Test name Executions per second
Lodash 9923.6 Ops/sec
JS some 9821.8 Ops/sec
HTML Preparation code:
x
 
1
2
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script>
Script Preparation code:
 
function getRandomString(length) {
  const charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
  let result = "";
  for (let i = 0; i < length; i++) {
    const randomIndex = Math.floor(Math.random() * charset.length);
    result += charset.charAt(randomIndex);
  }
  return result;
}
function getRandomBoolean() {
  return Math.random() < 0.5; // Generates true or false with roughly equal probability
}
function generateArrayOfJSONObjects(length) {
  const jsonArray = [];
  for (let i = 0; i < length; i++) {
    const jsonObject = {
      name: getRandomString(10), // Change 10 to the desired length of the random string
      value: getRandomBoolean(),
    };
    jsonArray.push(jsonObject);
  }
  return jsonArray;
}
Tests:
  • Lodash

     
    const array = generateArrayOfJSONObjects(1000);
    const found = _.some(array, s => s.value);
  • JS some

     
    const array = generateArrayOfJSONObjects(1000);
    const found = array.some(s => s === 'oranges');