Closed rampall closed 13 years ago
It's a contextual keyword, so it only has special meaning when it follows for
and precedes another identifier. You can still use it as an identifier; you can even legally write for own own of own
if you want to be confusing.
Ah thanks!
P.S for own own of own
has quite a zen feel to it - i must admit
Please, consider the following: if own prop of obj then ...
which could compile to if (Object.prototype.hasOwnProperty.call(obj, prop)) {...}
and would literate-ize quite a common pattern, imho.
TIA,
--Vladimir
@dvv: own = (prop, obj) -> Object::hasOwnProperty.call obj, prop
allows you to do if own prop, obj then ...
. Not a perfect solution, but it's probably good enough. There was a previous suggestion for this, let me look it up. Can't find it, oh well.
sure. That is what i do so far in hope own will become truly helpful keyword. The reasons: each and every file must contain this purely routine shim; one may accidently overwrite 'own' implementation; chances are that compiler already included hasOwn helper which is then purely a bloat; braces required in case of complex objects.
I'm afraid this shouldn't be a keyword -- it's already a method on every object. We don't need to turn Object.prototype
methods into keywords just for convenience.
What if rename implicit __hasProp
to own
and always bundle it, so that the coffee code look clean?
is
own
a keyword?i don't see it mentioned (COFFEE_KEYWORDS) except in the documentation example: for own key, value of object