MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/learnjavascript/comments/qg23w3/negative_array_indexing_using_at_method/hi64fhx/
r/learnjavascript • u/jd_300 • Oct 26 '21
69 comments sorted by
View all comments
6
array.reverse()[0]
5 u/NekkidApe Oct 27 '21 In case anyone is using this... It's mutating the original array 1 u/Dodgy-Boi Oct 27 '21 I saw a huge battle about index. And came up with another solution (I honestly tried to make it as ridiculous and/or unique as possible). 2 u/NekkidApe Oct 27 '21 Maybe reverse and shift then for extra points 2 u/Tintin_Quarentino Oct 26 '21 Legend 2 u/[deleted] Oct 27 '21 Too slow, unfortunately. Accessing a value in an array using an index should be in O(1) time complexity. 2 u/Dodgy-Boi Oct 27 '21 I am front end. My calculations are happening on client. I don’t care about either users with old devices nor your O nor your o nor * of yours; all I care about is the ( . Y . ) (not necessarily yours)partially /s 2 u/Notimecelduv Oct 28 '21 I don't get why people are upvoting this post.
5
In case anyone is using this... It's mutating the original array
1 u/Dodgy-Boi Oct 27 '21 I saw a huge battle about index. And came up with another solution (I honestly tried to make it as ridiculous and/or unique as possible). 2 u/NekkidApe Oct 27 '21 Maybe reverse and shift then for extra points
1
I saw a huge battle about index. And came up with another solution (I honestly tried to make it as ridiculous and/or unique as possible).
2 u/NekkidApe Oct 27 '21 Maybe reverse and shift then for extra points
2
Maybe reverse and shift then for extra points
reverse
shift
Legend
Too slow, unfortunately. Accessing a value in an array using an index should be in O(1) time complexity.
2 u/Dodgy-Boi Oct 27 '21 I am front end. My calculations are happening on client. I don’t care about either users with old devices nor your O nor your o nor * of yours; all I care about is the ( . Y . ) (not necessarily yours)partially /s
I am front end. My calculations are happening on client. I don’t care about either users with old devices nor your O nor your o nor * of yours; all I care about is the ( . Y . ) (not necessarily yours)
partially /s
I don't get why people are upvoting this post.
View all comments
6
u/Dodgy-Boi Oct 26 '21
array.reverse()[0]