DEV Community

Discussion on: 10 Popular JavaScript methods implemented from scratch

Collapse
lukeshiru profile image
Luke Shiru

A little understanding of how JavaScript methods works inside will always help you as a developer.

Not really 😅 ... is like saying that knowing asm makes you a better dev. If you know how to use this methods, the underlying implementation doesn't matter much. Don't get me wrong, is fine if you implement this kind of things manually for fun, but my point is that is not that useful in "the real world". Other than that, you should avoid messing with native objects prototypes ... and you could also implement some of this methods with for...of, so for example map could be:

const map = callback => array => {
    const mappedArray = [];

    for (const item of array) mappedArray.push(callback(item));

    return mappedArray;
};

const mapDouble = map(item => item * 2);

mapDouble([1, 2, 3]); // [2, 4, 6]
Enter fullscreen mode Exit fullscreen mode

Cheers!

Collapse
northwillov profile image
Artem Verbitski Author

Yes, I totally agree with you.
You don't have to know how car engine works inside to drive a car, what I meant was
knowing how car engine works, makes you a better understanding of a car itself.

And you may be surprised but assembly language is still in use, so knowing such stuff definitely makes you a better dev 😜.

Cheers!

Collapse
lukeshiru profile image
Luke Shiru

COBOL is also in still in use, that doesn't mean you need to learn it to be a better WebDev 😅 ... and that analogy with the car doesn't apply here, because you don't debug the internals of Array.prototype.map (the engine), you just debug the usage of map. The folks working on the browser engine are the ones dealing with "the engine" 😄

Thread Thread
northwillov profile image
Artem Verbitski Author

These are only a light versions of "the engine". So we won't get a full understanding of it, but a light one.

For those who want to familiarize with the internals of JS methods e.g. Array.prototype.map you can find this information here: developer.mozilla.org/en-US/docs/W...

Thanks 😀

Collapse
lepinekong profile image
lepinekong

It's not the same thing as rebuilding a car engine, but it shows he knows javascript and datastructure. Sometimes you need an original algorithm if you software is a bit innovative, if you just do lame integration work then it's ok you don't need to understand much.

Collapse
lukeshiru profile image
Luke Shiru
  1. Isn't it calling integration work "lame" actually lame? I know folks that only do that and that's perfectly fine.
  2. Do you usually re-implement methods that come with your language of choice and are optimized at an engine level? Do you honestly believe that's useful?

It's ok to know how things work, but my point is that is not necessary and it doesn't make you a "better developer". Maybe if we were talking about a low level language, but re-implementing Array.prototype.map in JavaScript is kinda pointless. Is way more useful that you know when and how to use those methods, that if you know how they work internally.

Not only that, if you see questions like this in an interview for a JavaScript/TypeScript position, take that as a 🚩 red flag 🚩 and get out of there.

Thread Thread
lepinekong profile image
lepinekong • Edited on

I don't say ALL integration work are lame, I say that there are integration work that are lame that's why they are automatable why do you think lowcode/nocode are now rising and usable by just business people ;) dev.to/lepinekong/comment/1l7ab

Thread Thread
lukeshiru profile image
Luke Shiru

If you want to discuss no-code, then let's do it in there, this thread is about the need for developers to know about the underlying implementation of native methods, which from my point of view is pointless ... and if you bring no-code to the table, that feels more like an argument in favor of my point of view, tbh.

I also gave my two cents on that post about no-code, so if you want to discuss that topic further, feel free to do it there.

Thread Thread
lepinekong profile image
lepinekong • Edited on

I do SystemThinking : things are not separate ;) If I recruit a coder I will indeed want to be sure he master the fundamentals if not I would rather recruit the guy/girl for doing lowcode or nocode.

Thread Thread
lukeshiru profile image
Luke Shiru • Edited on

If you did ✨ community moderation ✨ you'll consider that talking about unrelated topics is 🌈spam🌈 (Just think about the author receiving notifications about something unrelated to their post) .... I guess we can leave it at "we agree to disagree".

Thread Thread
lepinekong profile image
Comment marked as low quality/non-constructive by the community. View Code of Conduct
Info Comment hidden by post author - thread only visible in this permalink
lepinekong

It's not my fault if you are narrow minded, just a joke also if you don't mind ;)

Some comments have been hidden by the post's author - find out more