-
Notifications
You must be signed in to change notification settings - Fork 84
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
Method set in simple paths #60
Comments
yes, because right now it considers '' as empty (along with false, null, undefined, 0, etc). if the path is empty, all functions return prematurely without trying further. although there isn't a use case where you'd want to set an empty string field on an object, can you show me one case that would be useful? |
I don't know if there are some case that is useful. Only it seems nice for me because keep behaviour expected. And it's posible to implement easily and generally for all methods using this function:
|
js objects right now can have just 2 types of keys: strings and Symbols. |
Hi. I checked this behaviour:
and var obj = {};
obj[null] = 'foo';
obj[null]; // 'foo'
obj['null']; // 'foo'
obj; // {null: 'foo'} in Firefox 42, Chorme 46 and node 0.12.0 and the behaviour is valid and does not throw any exception. Then I checked es6 specs and according to specifications it is the correct behaviour. In fact, key can be a Symbol, String or another type value(object, number, boolean, null, etc.) that it will be coerced to string based on specs. On other hand, I understand that this module aims to extend behaviour to get and set values deeply (a part of another methods). Therefore it is needed an array of keys to get or set values. For example, if you use this sentence In my point of view, one module should be focused in one thing to do. Another module could approach the issue of restricting keys. For this reason I proposed something similar to
|
indeed it's correct and that's the spec, but what we are trying to achieve is a consistent 'interface' for acessing properties. if by any means you pass an undefined variable (aka symbol support on the otherhand is coming to version 1.0, and is much safer then trying to use falsy values as a key, IMHO javascript is permissive when it shouldn't. trying to do |
Ok, I understand your opinion at almost cases (undefined, null, and non-string keys) because it usually a mistake and really does not restrict any feature. Form example:
but
But I do not agree about empty strings because restrict a valid behaviour that can not reproduce otherwise. But is only my opinion. Thanks! |
When it is passed a simple path to
set
method I expect to have the same behaviour of expression:Examples:
But exist in
set
method one case that it behaves different:I think that it would be a good idea change behaviour in this case to keep the consistency. I think the same for another methods.
The text was updated successfully, but these errors were encountered: