validate object is not defined code example
Example: javascript check if boolean is undefined
if (typeof myFlag !== "undefined") {
// comes here whether myFlag is true or false but not defined
}
if (typeof myFlag !== "undefined") {
// comes here whether myFlag is true or false but not defined
}