JAVASCRIPT

HOW TO CHECK VALUE EXISTS IN JAVASCRIPT OBJECT

THE OBJECT var theObj = {  Name: "Jon",  Email: "jon@doe.com" };

EXTRACT VALUES TO FLAT ARRAY, CHECK USING INCLUDES var values = Object.values(theObj); var check = values.includes("Jon"); console.log(check); // true

EXTRACT VALUES USE INCLUDES()

01

MANUAL LOOP AND CHECK

02

var musthave = "Jon"; var found = false; for (let key in theObj) {   if (theObj[key] == musthave)   { found = true; break; } } console.log(found); // true