Use the find() method: myArray.find(x => x.id === '45').foo;. From MDN: The find() method returns the first value in the array, if an element in the array ... ... <看更多>
In ES5, to find an element in an array, you use the indexOf() or lastIndexOf() methods. However, these methods are quite limited because they return the index ... ... <看更多>
First count the number of distinct numbers. You have called it n . Then SELECT COUNT(*) FROM tbl WHERE id IN (very-long-list). See if that returns n . ... <看更多>