Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Res.locals not an javascript Object #2771

Closed
trquoccuong opened this issue Oct 1, 2015 · 2 comments
Closed

Res.locals not an javascript Object #2771

trquoccuong opened this issue Oct 1, 2015 · 2 comments

Comments

@trquoccuong
Copy link

Hi . I think res.locals similar with app.locals (javascript Object) But I cant call buildin function hasOwnProperty .
http://stackoverflow.com/questions/32878954/object-javascipt-dont-have-build-in-function-hasownproperty

@dougwilson
Copy link
Contributor

Hi! This is because res.locals is meant to be a bag for you to store key value pairs, meaning it is perfectly OK to do res.locals.hasOwnProperty = 'foo' and everything will still work fine. If you need to call hasOwnProperty on it, you need to do Object.prototype.hasOwnProperty.call(res.locals, 'propName').

@wesleytodd
Copy link
Member

Sorry to bring this back up, but I think @trquoccuong's question is important. This is very unexpected behavior IMO. I think we should maybe consider changing this behavior in express 5.0. Is there somewhere this decision was made that I could read over so I understand more?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants