DEV Community

Discussion on: hasOwnProperty considered harmful

Collapse
 
gmartigny profile image
Guillaume Martigny

hasOwnPropery is a great way to prevent you from looping though the object prototype. Sorry, but I can't see any reason not to.

Where I agree with you, it's that you perform an unnecessary check. The best IMO, it not to avoid hasOwnPropery, but to prefer other loops like for( ... of ... ) or Object.keys().forEach().