'Il some()metodo controlla se alcuni valori dell'array superano un test.
'Questo esempio controlla se alcuni valori dell'array sono maggiori di 18: 'Esempio 'var numbers = [45, 4, 9, 16, 25]; 'var someOver18 = numbers.some(myFunction); 'function myFunction(value, index, array) { ' return value > 18; '} https://www.w3schools.com/js/tryit.asp?filename=tryjs_array_some <!DOCTYPE html> <html> <body> <h2>JavaScript Array.some()</h2> <p>The some() method checks if some array values pass a test.</p> <p id="demo"></p> <script> var numbers = [45, 4, 9, 16, 25]; var someOver18 = numbers.some(myFunction); document.getElementById("demo").innerHTML = "Some over 18 is " + someOver18; function myFunction(value, index, array) { return value > 18; } </script> </body> </html> 'Si noti che la funzione accetta 3 argomenti: 'Il valore dell'oggetto 'L'indice dell'oggetto 'La matrice stessa |