Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
tlrobinson
on Nov 12, 2009
|
parent
|
context
|
favorite
| on:
Google Closure: How not to write Javascript
If you want to super careful, obj.hasOwnProperty(key) is actually dangerous. What happens when obj has it's own property named "hasOwnProperty"?
The safest thing to do is:
Object.prototype.hasOwnProperty(obj, key)
Of course, as with the "undefined" example, malicious or incompetent code could overwrite Object.prototype.hasOwnProperty
Consider applying for YC's Spring batch! Applications are open till Feb 11.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search:
The safest thing to do is:
Of course, as with the "undefined" example, malicious or incompetent code could overwrite Object.prototype.hasOwnProperty