Determine whether the obj object contains the children attribute, but the following error occurs
Do not access Object.prototype method ‘hasOwnProperty’ from target object.
Cannot directly access methods on Object prototype
Reason:
It is not safe to call hasOwnProperty directly on the result object,If the obj object itself has the hasOwnProperty property,there will be some unexpected problems when calling it. If someone with intentions takes advantage of ,set the property in obj to malicious code, will cause some security issues.
Workaround:
Use call to change the call point
const hasChild = Object.prototype.hasOwnProperty.call(obj, 'children');