Git Product home page Git Product logo

Comments (4)

binury avatar binury commented on May 26, 2024 1

@binury

Yes, function pick(object, keys) implementation is correct.

Thank you for the information about #168.

maybe a PR to remove the destructured assignment lines, if you'd be willing/like to?

from you-dont-need-lodash-underscore.

binury avatar binury commented on May 26, 2024

True and this is covered by the native implementation outlined directly after the destructured assignment example, isn't it?

// Native
function pick(object, keys) {
return keys.reduce((obj, key) => {
if (object && object.hasOwnProperty(key)) {
obj[key] = object[key];
}
return obj;
}, {});
}
var result = pick(object, ['a', 'c']);
console.log(result)
// output: {a: 1, c: 3}

from you-dont-need-lodash-underscore.

binury avatar binury commented on May 26, 2024

I agree, though. Destructuring is not directly comparable to using _.pick really, at all. Looking at the blame, it seems like these lines were added as a shoehorned change in #168. And it's unclear enough as to why that I almost wonder if the changes slipped through review, all those years ago.

https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore/pull/168/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5R1918-R1924

from you-dont-need-lodash-underscore.

yoshikazusawa avatar yoshikazusawa commented on May 26, 2024

@binury
Yes, function pick(object, keys) implementation is correct.

Thank you for the information about #168.

from you-dont-need-lodash-underscore.

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.