javascript check if value exists in object code example

Example 1: how to check if object exists in javascript

if (typeof maybeObject != "undefined") {
   alert("GOT THERE");
}

Example 2: search if value exists in object javascript

var exists = Object.keys(obj).some(function(k) {
    return obj[k] === "test1";
});

Example 3: check object in array javascript

var obj = {a: 5};
var array = [obj, "string", 5]; // Must be same object
array.indexOf(obj) !== -1 // True

Example 4: check if field exists in object javascript

if ('field' in obj) {
}