Giter VIP home page Giter VIP logo

Comments (5)

Fil avatar Fil commented on June 2, 2024 1

It's a really intriguing bug. If you set Object.prototype._hello = "x"; and try the first test plot (aaplBollinger), it draws 1 line on the y axis. If you set Object.prototype._hello = "xxxxx" it draws 5 lines!

It could happen on any of the many places in our code where we iterate on an object's keys with for (key in object).

I don't think there is anything to fix here, but I'm curious as to where this happens.

from plot.

rockie-yang avatar rockie-yang commented on June 2, 2024

That is in order to get most natural grammar by patch functions to prototype.

For example, the function pick in underscore use.

_.pick({name: 'moe', age: 50, userid: 'moe1'}, 'name', 'age');

And in ramda, it use

R.pick(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); 

I would argue that the most natural way shall be either

{a: 1, b: 2, c: 3, d: 4}.pick(['a', 'b'])

or

{a: 1, b: 2, c: 3, d: 4}.pick('a', 'b')

from plot.

mbostock avatar mbostock commented on June 2, 2024

You shouldn’t modify global prototypes such as Object.prototype. All bets are off when you do that!

from plot.

rockie-yang avatar rockie-yang commented on June 2, 2024

Thanks a lot @Fil and @mbostock for clarification. Does D3 has this prerequisite as well?

from plot.

mbostock avatar mbostock commented on June 2, 2024

Like I said, all bets are off. There’s no way of knowing how any library will behave if you start modifying global prototypes.

from plot.

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.