es6 check if object exists code example
Example 1: how to check if object exists in javascript
if (typeof maybeObject != "undefined") {
alert("GOT THERE");
}
Example 2: check if js property exists in class
myObj.hasOwnProperty(myProp)
if (typeof maybeObject != "undefined") {
alert("GOT THERE");
}
myObj.hasOwnProperty(myProp)