3 ms·
Then this page could be replaced by looking at lodash's source code. In fact this page is harmful as it does not represent, precisely, what lodash is actually
by Zetice 4y ago
Then this page could be replaced by looking at lodash's source code. In fact this page is harmful as it does not represent, precisely, what lodash is actually doing and should not be used to understand lodash.
Further, I'm not responding to the page itself, but the discussion here around the page. A lot of developers are using their emotions (e.g. disgust, fear) to navigate their professional role, and I'm suggesting that this need not be the case.
You can set all of that aside and be a highly effective developer. You don't need to care about any of this, and I'm seeing a lot of devs here who think they have to care in order to be effective.
- whstl 4y agoIt couldn't be replaced by looking at Lodash's source code, because A LOT of the alternatives here are built into Javascript, and the Lodash code is significantly larger. Check flatten in this website: array.flat(); Versus Lodash: function baseFlatten(array, depth, predicate, isStrict, result) { predicate || (predicate = isFlattenable) result || (result = []) if (array == null) { return result } for (const value of array) { if (depth > 0 && predicate(value)) { if (depth > 1) { // Recursively flatten arrays (susceptible to call stack limits). baseFlatten(value, depth - 1, predicate, isStrict, result) } else { result.push(...value) } } else if (!isStrict) { result[result.length] = value } } return result } About your point: sure, nobody has to care about all of this. But I don't see why we should give people a hard time because they do on their free time.
- Zetice 4y agoExactly; lodash doesn't use `array.flat()`, so the site does not teach, "how it's implemented." And I'm not giving people a hard time, I'm saying you don't have to care about all of this to be good at your developer job. If this was an obvious point to you, great!
- whstl 4y agoThe point of this website is not to show how Lodash implements things. Why would it be? It says so in there: it is "a description of how one would go about doing the same thing in vanilla JavaScript".
- Zetice 4y agoYou're arguing with yourself now, as I just quoted you: > This page is here, for example, so that people who only know about Lodash can know how it's implemented.
- whstl 4y agoI said "for example".
- Zetice 4y agoYes, and I responded to that example. Not sure what the problem is. Do you not think it's a good example?
- deleted 4y ago[deleted]
- whstl 4y agoTo be more precise, my point was more that this website shows how it is implemented in general. There is still something to be gained by showing that you can do array.flat() instead of just copy pasting from Lodash.
- Zetice 4y agoYes, for sure, I didn't mean to imply the website is entirely worthless, sorry. But my larger point here is just that you don't have to care about "only importing lodash if absolutely necessary" to be a good dev. You can care about those things, but for the folks who think they have to care, I'm here to say you don't.