Hoppa till huvudinnehåll

7 inlägg taggade me "javascript"

Visa Alla Taggar

Mouse, Touch and Pointer events

· 5 min att läsa
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 att läsa
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.

IP Location

· En minut att läsa
Filip Tammergård
Software Engineer at Einride

You live close to , right?

How did I know that? I used Ipapi! A neat API for getting the location of IP addresses, with 30,000 free lookups per month.

Uniquify array

· 2 min att läsa
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

· En minut att läsa
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!