Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Why would you use mockObject.getPath('/baz/zar/zog') over mockObject.baz.zar.zog? Unless getPath is null safe and you expect that sometimes part of the chain doesn't exist, but the docs for getPath don't indicate that as a feature.


> Unless getPath is null safe and you expect that sometimes part of the chain doesn't exist

Yes, that's exactly why.

> the docs for getPath don't indicate that as a feature.

The docs currently state 'If any of the keys are missing, return undefined. ' Perhaps they should be more explicit? If so I'm happy to take suggestions / pull requests.


I must have missed that in the docs.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: