How can we search anything from Object in JavaScript?
Firstly we have to know what is object in Javascript(JS ). JavaScript object is a standalone entity that holds multiple values in terms of properties and methods.
var person = {
firstName: "James",
lastName: "Bond",
age: 25
};
Properties are firstName, lastName, and age values of person object James, Bond and 25. We want to search any value from object-likeike the if the user wants to search Jemas it will return the Person object and Bond and Age anything from Object.
const array = [
{id:”1", name:”lkon”,email:”a@gmail.com"},
{id:”2", name:”kkon”,email:”b@gmail.com"},
{id:”3", name:”mkon”,email:”c@gmail.com”},
{id:”4", name:”nkon”,email:”d@gmail.com”},
{id:”5", name:”okon”,email:”e@gmail.com”},
{id:”6", name:”pkon”,email:”f@gmail.com”},
{id:”7", name:”qkon”,email:”g@gmail.com”},
{id:”8", name:”rkon”,email:”h@gmail.com"}
]
firstly we have pass data value to the function like as functionName(value){
FUNCTION BODY
}
const onChangeSearch = (e) => {
const values = e.target.value;
for (let i = 0; i < array.length; i++) {
const object = array[i];
let allValueObject = Object.values(object);
for (let j = 0; j < allValueObject.length; j++) {
const element = allValueObject[j];
if (element.toLocaleLowerCase() == values) {
console.log(“Find OBJECT:”, object);
return;
}else{
console.log(“NOT FIND”);
}
}
}
}
in AllValueObject will return the all object values as a Array allValueObject=[lkon,a@gmail.com] for every index of main array it will return an object value as a array then We have to search things array which is we get from the allValueObject.


Eventually, if we run pass the data onChangeSearch function nKon or h@gmail.com it will console the object which is similar to the value;
Thank you