Feed aggregator
Stop Being a Junior Software Engineer
Article URL: https://kentcdodds.com/blog/stop-being-a-junior
Comments URL: https://news.ycombinator.com/item?id=39848190
Points: 1
# Comments: 1
A Cryptocurrency Startup Utopia Became a Nightmare for Honduras
Article URL: https://foreignpolicy.com/2024/01/24/honduras-zedes-us-prospera-world-bank-biden-castro/
Comments URL: https://news.ycombinator.com/item?id=39848180
Points: 1
# Comments: 0
Representing State as Interfaces in Go
Article URL: https://www.emoses.org/posts/resolver-resolved-pattern/
Comments URL: https://news.ycombinator.com/item?id=39848164
Points: 1
# Comments: 0
List of Ig Nobel Prize Winners
Article URL: https://en.wikipedia.org/wiki/List_of_Ig_Nobel_Prize_winners
Comments URL: https://news.ycombinator.com/item?id=39848147
Points: 1
# Comments: 1
For young people, the job search has never been so miserable
Article URL: https://www.ft.com/content/4b16c325-8758-4b90-bdb5-15536b401606
Comments URL: https://news.ycombinator.com/item?id=39848140
Points: 6
# Comments: 0
Take-Two is acquiring Gearbox Software from Embracer for $460M
The Call of the Weird
Article URL: https://www.lrb.co.uk/the-paper/v46/n07/michael-ledger-lomas/the-call-of-the-weird
Comments URL: https://news.ycombinator.com/item?id=39848126
Points: 1
# Comments: 0
'He is not well': Concerns over Julian Assange's mental health [video]
Mnemonic for Shift() and Unshift()?
JavaScript push() and pop() are intuitive method-names because they come from the context of using an array as a "stack". You can "push" things to a stack meaning a new item is added as the new last element of the array. push() pushes a new element into the array. Pop() pops one off it.
shift() and unshift() on the other hand I always had trouble with. One of them adds a new element to the front of the array and the other removes and returns the 1st element. But which is which? I can google the answer but would be nice if I didn't have to google. And worse, sometimes I got confused between the two and used shift() where unshift() should have been used => Error,, stack overflow!
So I googled for "Mnemonics for shift() and unshift()", and found an entry on Stack Overflow. But that question was "Closed because the answers are opinion-based". I looked at the answers available but none of them struck me as particularly memorable.
Now after years of struggling with this confusion I think I've come up with a mnemonic I can live with:
Word "shift" is shorter than the word "unshift". Therefore shift() makes the array shorter.
Word "unshift" is longer than the word "shift". Therefore unshift() makes the array longer.
I know it doesn't really explain it, but it is a rule I can remember. I would appreciate hearing how anybody else remembers when to use shift() and when to use unshift().
Comments URL: https://news.ycombinator.com/item?id=39848102
Points: 1
# Comments: 0
Why human brains were bigger 3k years ago?
Article URL: https://www.bbc.com/future/article/20220503-why-human-brains-were-bigger-3000-years-ago
Comments URL: https://news.ycombinator.com/item?id=39848020
Points: 1
# Comments: 0
Ancient giant dolphin discovered in the Amazon
Article URL: https://www.cnn.com/2024/03/26/world/giant-dolphin-fossil-amazon-pebanista-yacuruna-scn/index.html
Comments URL: https://news.ycombinator.com/item?id=39847987
Points: 1
# Comments: 0