Skip to main content

7 posts tagged with "javascript"

View All Tags

Mouse, Touch and Pointer events

· 5 min read
Filip Tammergård
Software Engineer at Einride

I recently stumbled upon a bug related to the subtle differences between mouse, touch and pointer events. The bug made me confused—and curious. What is actually the difference between these events?

I opened an issue for the bug that you can check out if you're also curious—but before trying to understand the bug, we need to set the stage with some knowledge around different types of events.

|| vs ??

· 2 min read
Filip Tammergård
Software Engineer at Einride

|| and ?? are similar, but there's some very important nuance. Take a look at this example:

const a = "" || "default value"
// > "default value"

const b = "" ?? "default value"
// > ""

Let me explain.

Uniquify array

· 2 min read
Filip Tammergård
Software Engineer at Einride

Consider this array of names:

const names = [
"Filip",
"Anna",
"Jennifer",
"Anna",
"Robert",
"Emma",
"Filip",
"Anna",
]

In this array, Filip occurs two times and Anna three times. What if we want filter out the duplicates and get an array with the unique names?

Alphabet game

· One min read
Filip Tammergård
Software Engineer at Einride

In this game, you're supposed to write the alphabet as fast as you can. Click the input box and start the game by typing the first letter of the alphabet. My highscore is 2.95 seconds. Beat that if you can!