Correct comparison should be val with arrVal.Productomschrijving:
Copyfunction checkAvailability(arr, val) {
return arr.some(function(arrVal) {
return val === arrVal.Productomschrijving;
});
}
Answer from dfsq on Stack OverflowMDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Array › some
Array.prototype.some() - JavaScript | MDN
The some() method of Array instances returns true if it finds an element in the array that satisfies the provided testing function. Otherwise, it returns false.
Top answer 1 of 5
7
Correct comparison should be val with arrVal.Productomschrijving:
Copyfunction checkAvailability(arr, val) {
return arr.some(function(arrVal) {
return val === arrVal.Productomschrijving;
});
}
2 of 5
2
do you have to use some() method
why not simply? check this fiddle
Copyvar objArray = [
{ name : "Product X", amount : 10 },
{ name : "Product X", amount : 100 },
{ name : "Product X", amount : 40 },
]
var newArray = [];
var keyValue = {};
for ( var counter = 0; counter < objArray.length; counter++ )
{
var obj = objArray[ counter ];
if ( !keyValue[ obj.name ] )
{
keyValue[ obj.name ] = 0;
}
keyValue[ obj.name ] += obj.amount;
}
for ( var key in keyValue )
{
newArray.push( { name: key, amount : keyValue[ key ] } );
}
console.log( newArray );
Videos
JavaScript Tip: Retrieving a Property from an Array of Objects
02:34
How To Add Object to JavaScript Array - YouTube
JavaScript Array Methods in Minutes: SOME() — 3 EXAMPLES! - YouTube
02:00
Check If Some Items Pass a Condition - JavaScript Array Some (In ...
14:58
Array some Method in JavaScript | JavaScript Array Methods | ...
What does the SOME() array method do? - YouTube
W3Schools
w3schools.com › jsref › jsref_some.asp
JavaScript Array some() Method
The some() method checks if any array elements pass a test (provided as a callback function).
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Array
Array - JavaScript | MDN
* Some parts of this feature may have varying levels of support. ... The Array object, as with arrays in other programming languages, enables storing a collection of multiple items under a single variable name, and has members for performing common array operations.
Ultimate Courses
ultimatecourses.com › blog › array-some-javascript
Exploring Array Some in JavaScript - Ultimate Courses
You can change the this context via a second argument to .some(callback, thisArg) so that any references to this inside your callback point to your object · You can use arrow functions with Some but remember that this will be incorrect if you also supply a thisArg due to arrow functions not having a this context · Using Some will skip empty array slots as if it were a falsy value · You shouldn’t need to in this day and age of evergreen browsers, but use a polyfill for older browsers if necessary · Thanks for reading, happy Someing! Go to the next article in Exploring JavaScript Array Methods - Array Every!
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › TypedArray › some
TypedArray.prototype.some() - JavaScript | MDN
The some() method of TypedArray instances returns true if it finds an element in the array that satisfies the provided testing function. Otherwise, it returns false. This method has the same algorithm as Array.prototype.some().
Programiz
programiz.com › javascript › library › array › some
Javascript Array some() (with Examples)
Become a certified JavaScript programmer. Try Programiz PRO! ... The some() method tests whether any of the array elements pass the given test function.
Scaler
scaler.com › home › topics › what is an array of objects in javascript?
What is an Array of Objects in JavaScript? - Scaler Topics
April 2, 2024 - An array in javascript is the collection of multiple types of data at a single place in order, and an array of objects in javascript is a collection of homogenous data, that stores a sequence of numbered objects at a single place.
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Array › every
Array.prototype.every() - JavaScript | MDN
The array argument is useful if you want to access another element in the array. The following example first uses filter() to extract the positive values and then uses every() to check whether the array is strictly increasing.
JavaScript Tutorial
javascripttutorial.net › home › javascript array methods › array.prototype.some()
JavaScript Array some() Method
November 8, 2024 - The following example shows how ... Code language: JavaScript (javascript) ... How it works. First, define a range object with min and max properties....
Reality Ripple
udn.realityripple.com › docs › Web › JavaScript › Reference › Global_Objects › Array › some
Array.prototype.some() - JavaScript
The some() method tests whether at least one element in the array passes the test implemented by the provided function.
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-access-array-of-objects-in-javascript
How to Access Array of Objects in JavaScript ? - GeeksforGeeks
Using the brackets notation, you access objects in an array by specifying the array's name and the desired index. This method retrieves the entire object at the specified index. To access specific properties, combine it with dot notation for ...
Published July 23, 2025
TutorialsPoint
tutorialspoint.com › home › javascript › javascript array some() method
JavaScript Array some() Method
September 1, 2008 - In JavaScript, the Array.some() method takes a callback function and verifies whether at least one element in the array passes the test provided by the callback function. If at least one element passes the test, it returns "true".
Medium
medium.com › poka-techblog › simplify-your-javascript-use-some-and-find-f9fb9826ddfd
Simplify your JavaScript – Use .some() and .find() | by Etienne Talbot | poka-techblog | Medium
September 5, 2019 - As for .some() , you are clearly checking if the array contains items that fit your needs or not. Make your code clearer! Use .find() and .some() when relevant. Hopefully you’ve learned something new. Share the knowledge with your fellow developers! Do you know of more JavaScript gems that ...
Can I Use
caniuse.com › mdn-javascript_builtins_array_some
JavaScript built-in: Array: some | Can I use... Support tables for HTML5, CSS3, etc
"Can I use" provides up-to-date browser support tables for support of front-end web technologies on desktop and mobile web browsers.