Reputation: 4922
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?
Upvotes: 0
Views: 155
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