3 ms·
I'm not sure why you were downvoted. Yes we all understand JavaScript is prototype based and it's certainly possible for a malicious developer to muck with the
by nogridbag 12y ago
I'm not sure why you were downvoted. Yes we all understand JavaScript is prototype based and it's certainly possible for a malicious developer to muck with the prototype of your object. In the real world when you have control over the object in question (which imho is the majority of cases) there's no need to call hasOwnProperty.
- shawnz 12y agoI agree that it was a good question which shouldn't have been downvoted. But I don't think malicious developers are the real concern in this situation. Rather, it is just a matter of defensive programming. By not using hasOwnProperty (or better yet, ES6 maps), you are creating code that could break just by including a new dependency in the project.
- jvickers 12y agoThank you for your support in this difficult time.
- jvickers 12y agoIn my programming, I have not built it in a way to prevent a malicious developer from changing object prototypes. If there is actually an attack vector that gets closed by checking hasOwnProperty I'm interested.