GirkovArpa
GirkovArpa

Reputation: 4922

Why does replacing the apple emoji replace all fruit emojies?

I was reading this V8 blog post about the new String.prototype.replaceAll where they show this example:

console.log(
  '🍏🍏🍋🍋🍊🍊🍓🍓'.replace(/🍏/g, '🥭')
)

Why are all fruits being replaced instead of just the green apple?

screenshot

Upvotes: 0

Views: 155

Answers (1)

jmrk
jmrk

Reputation: 40691

This is almost certainly a question of which fonts you have installed on your system.

When I first saw this question, I only saw square boxes, before and after replacing. Installing the "Noto Emoji" font and restarting my browser fixed it for me: now I see fruits, including a tomato to replace the apple with.

JavaScript (and V8) does what you'd expect; you just need to get your system to render the emoji for you correctly.

Upvotes: 1

Related Questions