Introduction
In this article I wanted to share with you with the most popular JavaScript methods but implemented by scratch.
A little un...
Some comments have been hidden by the post's author - find out more
For further actions, you may consider blocking this person and/or reporting abuse
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!
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 π
sort
should work in place:tc39.es/ecma262/#sec-array.prototy...
developer.mozilla.org/en-US/docs/W...
Hi!
These are only a light versions of popular methods in JS, and of course the original methods mentioned in ECMAScript are much more complex and useful.
Thank you for comment :)
Nice. Fundamentals are worth knowing. Developers are like engineers who build engines, so if you donβt understand how a single part of the engine you want to build works, than you are going to be some kind of mere dev because trial and error are what you are going to be on all times.
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.
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
Useful
Good article, but you forgot to include the
return -1
for.indexOf
Thanks for noticing! I made an update.
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.
Are these implementations faster than native ones?
Nice Post
Good try but most of the Algorithms are wayyyyyy too slow to use, for example, your sort algorithm is taking O(N^2) time too slow.
As ECMAScript doesnβt specify any sorting algorithm to be implemented by
Array.prototype.sort()
, it totally depends on browser which sorting algorithm to be implement.Safari, Webkit, etc. uses 'Selection Sort' whereas Mozilla uses 'Merge Sort'.
The sorting algorithm behind
.fakeSort()
mentioned in this article is 'Bubble Sort', and is intended for educational purposes and isnβt an efficient method for sorting in real world.Bubble Sort also is one of the most widely discussed algorithms, simply because of its lack of efficiency for sorting arrays. If an array is already sorted, Bubble Sort will only pass through the array once, however the worst case scenario is a run time of O(NΒ²), which is extremely inefficient.