Giter Site home page Giter Site logo

Comments (4)

wimbarelds avatar wimbarelds commented on July 19, 2024

Array.prototype can have methods added to it

That's a good point. I mean, people probably shouldn't, but better to be safe. I'll stop using this to iterate through arrays.

Just to be clear, there should be no problems using it to iterate through custom objects made using {}, right?

from timecircles.

lewang avatar lewang commented on July 19, 2024

On Mon, Jul 7, 2014 at 11:45 AM, wimbarelds [email protected]
wrote:

Array.prototype can have methods added to it

That's a good point. I mean, people probably shouldn't, but better to be
safe. I'll stop using this to iterate through arrays.

Agreed. Adding things to Array.prototype probably has unintended
consequences.

Just to be clear, there should be no problems using it to iterate through
custom objects made using {}, right?

No, you will still hit custom methods defined on Object.prototype. Use a
hasOwnProperty check or preferrably iterate through the array returned
from Object.keys().

from timecircles.

wimbarelds avatar wimbarelds commented on July 19, 2024

The problem with Object.keys is IE8 support, though I suppose that's becoming an edge case and it might be better to use Object.keys and create a fallback for IE8- as opposed to using a sub-optimal solution for all other browsers.

from timecircles.

wimbarelds avatar wimbarelds commented on July 19, 2024

Eradicated use of the for(key in obj/arr) in version 1.5. Thanks for the tip!

from timecircles.

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.