When grabbing an index from an array if I give an index that is below zero, or above the length of the array, it does not wrap around and give me whatever element it would be if I adjusted the index value.
That is if I think about an array being this thing like that of a circle, rather than an infinite line than I am going to be disappointed without some kind of helper method.
I wrote a post on the nature of the modulo operator, and why it does not work the way that you might expect it to. So if you attempt to correct the given index value like this:
You are going to have a bad time. That would be a pretty sleek one liner if it worked, and it will work with positive values that go equal to or beyond the length of the array, but not with negative index values.
As such you would need to do something else.
Making a vanilla js alternative to _.nth just involves working out how to make a modulo operation that works a different way in which a positive, valid, in range value is always given.
These lodash methods are helpful, many even though many of them can be written quickly, it still saves time. I know that lodash is now one of those projects like jQuery where much of this is no longer needed, but even when a method like that comes along lodash still helps with backward compatibility with those older browsers people still use.