Learning JSX here and I was wondering if theres a way to check if a value appears in a object in JavaScript
ie We have an obj : anObj ={ myFoo: "MONDAY;TUESDAY;WEDNESDAY" }
How could I check if monday etc appears in this object?
You can find the value in Object.values with.includes()
let valueExists = Object.values(obj).includes("value you looking for");
You can check in the values array
const valuesArray=Object.values(anyObj);
console.log(valuesArray.some((value)=>value.includes('monday'))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.