4 ms·
You don't need to do that. You just use a library. import { isArrayLike, values } from 'ramda'; const a = []; const aIsArray = isArrayLike(a); co
by lhnz 11y ago
You don't need to do that. You just use a library.
import { isArrayLike, values } from 'ramda';
const a = [];
const aIsArray = isArrayLike(a);
const d = {
a: [1,2,3,],
b:[4,5]
};
const dValues = values(d);
Not to mention that a lot of the problems you mention have native solutions in ES6.
JavaScript is a very different language than the one people used to use 5 years back.
- WorldWideWayne 11y agoWhich library? From where? Never heard of ramda, but I can tell you it's not standard. Why should people use JS with a non-standard library when dictionaries come built into better languages?
- lhnz 11y agoThe library is ramdajs.com and it can be grabbed from npm. I do not agree that everything should be handled with standard libraries. It's better for these things to be modular and versioned, instead of them being pulled from a big bloated standard library. The code clearly does what was being asked in a very simple and non-broken way. Perhaps the issue here is that non-JavaScript engineers are used to kitchensink standard libraries and avoid mixing and matching to get the best experience the ecosystem offers.
- WorldWideWayne 11y agoYou're building a straw-man there. A standard library can certainly be made to be modular and versioned. It doesn't have to be bloated for any reason whatsoever. This is Javascript - you can chop up your scripts however you want. The problem with mixing and matching libs is that no two JS devs do it the same. Some will even re-build the same lib that has already been built by hundreds of JS devs because NIH.
- lhnz 11y agoYou are the one that has built a strawman. In your universe, engineers do not talk and accidentally decide to use two libraries that do the same thing within a project. I work with JavaScript and I rarely see this happening.