I like to build cool things, work with nice people and help others where I can. Currently I'm an engineering manager for a fintech startup and historically a serial founder & freelancer software dev.
Location
München, Deutschland 🇩🇪
Education
The Open University
Work
Engineering Manager @ Deutsche Fintech Solutions GmbH
It won't go out of range since the const next = inner + 1; will return undefined when we try to do a lookup on output[next] for the last item in the iterable.
This being the case no swap happens and no error throws, in other languages it would though but this is JavaScript and so we don't need to mitigate anything here.
I like to build cool things, work with nice people and help others where I can. Currently I'm an engineering manager for a fintech startup and historically a serial founder & freelancer software dev.
Location
München, Deutschland 🇩🇪
Education
The Open University
Work
Engineering Manager @ Deutsche Fintech Solutions GmbH
With
const next = inner + 1
won't you go out of range when inner = length - 1?How did you do the animation?
It won't go out of range since the
const next = inner + 1;
will return undefined when we try to do a lookup onoutput[next]
for the last item in the iterable.For example:
This being the case no swap happens and no error throws, in other languages it would though but this is JavaScript and so we don't need to mitigate anything here.
I got the animation from Geeks for Geeks.
OK thanks for the explanation. Good series it is a great refresher
All good. Glad you’ve been enjoying the series so far!