Loose search
const arr = [
{ name: "John Mulaney" },
{ name: "Bill Burr" },
{ name: "Tom Segura" },
];
const query = "John Mulaney";
const filteredArr = arr.filter((item) =>
item.name.toLowerCase().includes(query.toLowerCase())
); // [{name: "John Mulaney"}]
Strict search
const arr = [
{ name: "John Mulaney" },
{ name: "Bill Burr" },
{ name: "Tom Segura" },
];
const query = "John Mulaney";
const filteredArr = arr.filter(
(item) =>
query.toLowerCase() === item.name.toLowerCase().substring(0, query.length)
); // [{name: "John Mulaney"}]