I am at a loss to decide whether the question is "variable defined" or "property defined", but I will answer from both perspectives.
This code does not work as expected when
The null and undefined types do not have primitive wrapper objects and cannot have properties.
Use the in operator to determine the existence of properties including prototype chains such as your publication, except for Undefined and Null types that do not have the property.
As you can see from the previous code, if the variable containing the object is undefined, it will be ReferenceError
You must use the
typeof operator to avoid
ReferenceError, but even if you function the
ReferenceError occurs at the time of function call.
To accommodate undefined variables, you must use the
typeof operator before calling the function.
If you want to exclude inherited properties, why not use hasOwnProperty
How about this kind of kanji?
© 2022 OneMinuteCode. All rights reserved.