some()
MethodYou can use the JavaScript some()
method to find out if a JavaScript array contains an object.
This method tests whether at least one element in the array passes the test implemented by the provided function. Here's an example that demonstrates how it works:
<script>
// An array of objects
var persons = [{name: "Harry"}, {name: "Alice"}, {name: "Peter"}];
// Find if the array contains an object by comparing the property value
if(persons.some(person => person.name === "Peter")){
alert("Object found inside the array.");
} else{
alert("Object not found.");
}
</script>
Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on [email protected]
How to get Current User Location in Laravel 7
In this tutorial, i am going to show you...How to remove white space from the end of a string in PHP
Use the PHP rtrim() function...Laravel User Email Verification and Account Activation Example
Today, Laravel is a most popular PHP fra...How to redirect www URLs to non-www
When considering to SEO, if you are not...How to Create Module in Angular9?
What is NgModule in Angular? If you a...