OzosStackOverflow
OzosStackOverflow

Reputation: 51

Checking if a value exists in JavaScript Object

Learning JSX here and I was wondering if theres a way to check if a value appears in a object in JavaScript

i.e We have an obj: anObj ={ myFoo : "MONDAY;TUESDAY;WEDNESDAY" }

How could I check if monday etc appears in this object?

Upvotes: 0

Views: 781

Answers (1)

Grant Solomons
Grant Solomons

Reputation: 241

You can find the value in Object.values with .includes()

let valueExists = Object.values(obj).includes("value you looking for");

Upvotes: 2

Related Questions