-
Notifications
You must be signed in to change notification settings - Fork 175
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
hasOwnProperty quirk #53
Comments
Thanks @dvv. We'll change it wherever we make that call. Do you know why a direct call to hasOwnProperty is not consistent? |
Have no idea so far. I guess because update2: exactly because update3: this might be the reason why this change fixes the issue: there also exist objects which have no |
Javascript is a silly language. I suppose this is something that should be changed. Iteration through objects is a mess in this language. |
Sure. Two options: rely upon underscore, which is all about convenient iterations over "lists", normalizing hashes and arrays; or CS which has clean syntax for that ;) The third option is to very carefully code inline patterns, or reinvent own set of helpers -- this usually leads to nowhere in the long run. |
@dvv Why not fork and write you own CoffeeScript version? Sounds like it's so easy and convenient that you'd be done in a few hours. |
Of course not. I'm just trying to help biting problems I see. Plus, it will be useless unless it's accepted into the master. The whole point I'm asking whether CS source is feasible to have is to explore the field of your opinions. I'm not trying to force using CS in any way. |
Thanks for both of your contributions guys. Dvv has been very polite in helping us out. More awareness of best practices can't hurt. |
@dvv I have changed all Is there a benefit of using |
Thanks! I guess the latter costs one more hop along the prototype chain. They just teach us augmenting/mangling |
Hi!
https://github.com/Flotype/now/blob/master/lib/nowUtil.js#L86:
Sometimes causes the falsy negatives -- i.e. I pass a hash which surely is created from scratch (by literal notation) and the function returns false. When I change it to be
Object.hasOwnProperty.call(currVar, prop)
the result is positive.Notice, that in CoffeeScript (which compiles to a "least common denominator" JS code, which runs on every JS engine), they use namely the said signature --
Object.hasOwnProperty.call(obj, prop)
to determine whether a property is own.I'd recommend to introduce a helper
function __isOwnProp(obj, propName){return Object.hasOwnProperty.call(obj, propName)}
and rewrite all invocations ofobj.hasOwnProperty(prop)
.Sorry for being didactic, and TIA,
--Vladimir
The text was updated successfully, but these errors were encountered: