Closed jharmn closed 5 years ago
@jasonh-n-austin Can you use forOwn function? Everything else, looks good :+1:
I tried forOwn, but it doesn't seem to work the same way. It still iterates prototyped methods.
What is your environment? I tried lodash example and it works fine. Can you try it on your system?
function Foo() {
this.a = 1;
this.b = 2;
}
Foo.prototype.c = 3;
_.forOwn(new Foo, function(value, key) {
console.log(key);
});
// → logs 'a' and 'b' (iteration order is not guaranteed)
I also inspect lodash implementation and it use standard Object.keys
, can you log output of this function?
@jasonh-n-austin Did you had a chance to look at it?
Hi @jasonh-n-austin,
Happy New Year :christmas_tree: :santa: Is this issue still valid?
Totally forgot about this. I'll take a look at it by the end of the week, thanks for the reminder.
Ran your test script on v0.10.25
/Ubuntu and v0.12.1
/Mac, both printed a
,b
.
I'll re-run this with my test data and see if I can figure out what scenario made this necessary.
FYI @crankydillo has been working on some improvements (which are now included in this PR). I've also asked for his help to pin down why we needed this prototype exclusion to make things work (my brain is already full of cobwebs about it).
@jasonh-n-austin
why we needed this prototype exclusion to make things work
I understand why. But I'm don't understand why forOwn
not working?
can you try to do:
data = JSON.parse(JSON.stringify(data));
before passing it into the lib?
Assuming this PR is no longer relevant/current? Happy to re-open if necessary.
When prototype methods have been added to the GDD schema, iterations of object properties will fail.
http://yuiblog.com/blog/2006/09/26/for-in-intrigue/