Git Product home page Git Product logo

Comments (9)

sridatta avatar sridatta commented on June 20, 2024

Thanks @dvv. We'll change it wherever we make that call. Do you know why a direct call to hasOwnProperty is not consistent?

from now.

dvv avatar dvv commented on June 20, 2024

Have no idea so far. I guess because obj.hasOwnProperty itself can be overridden.
update: they use __hasProp = Object.prototype.hasOwnProperty (notice prototype)

update2: exactly because obj.hasOwnProperty itself can be tainted/overridden

update3: this might be the reason why this change fixes the issue: there also exist objects which have no hasOwnProperty in their prototype -- the most prominent is null ;)

from now.

ericz avatar ericz commented on June 20, 2024

Javascript is a silly language. I suppose this is something that should be changed. Iteration through objects is a mess in this language.

from now.

dvv avatar dvv commented on June 20, 2024

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.

from now.

erichocean avatar erichocean commented on June 20, 2024

@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.

from now.

dvv avatar dvv commented on June 20, 2024

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.

from now.

ericz avatar ericz commented on June 20, 2024

Thanks for both of your contributions guys. Dvv has been very polite in helping us out. More awareness of best practices can't hurt.

from now.

ericz avatar ericz commented on June 20, 2024

@dvv I have changed all obj.hasOwnProperty to Object.hasOwnProperty.call

Is there a benefit of using Object.prototype.hasOwnProperty.call vs Object.hasOwnProperty.call ??

from now.

dvv avatar dvv commented on June 20, 2024

Thanks!

I guess the latter costs one more hop along the prototype chain. They just teach us augmenting/mangling Object.prototype is bad practice, so they assume Object.prototype.hasOwnProperty is pristine in either case.

from now.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.