DEV Community

Atif Riaz
Atif Riaz

Posted on

2 1

⚡JS Tip: Create Emoji Characters in JavaScript using String.fromCodePoint();

The String.fromCodePoint() method was added to ECMAScript 2015. The result of this method is a string (and not a String object).
Because fromCodePoint() is a static String method, you must call it as String.

let smile = String.fromCodePoint(128516); // '128516' is character code
let str = `I got you ${smile}!`;
console.log(str);
// output: "I got you 😄!" 


Enter fullscreen mode Exit fullscreen mode

You can create emoji characters in JavaScript using String.fromCodePoint( );

Syntax

Here is the syntax:

String.fromCodePoint(num1)
String.fromCodePoint(num1, num2)
String.fromCodePoint(num1, num2, ..., numN)

Enter fullscreen mode Exit fullscreen mode

Initially created on Twitter

If you liked this article, be sure to ❤️ it.

Sentry blog image

How I fixed 20 seconds of lag for every user in just 20 minutes.

Our AI agent was running 10-20 seconds slower than it should, impacting both our own developers and our early adopters. See how I used Sentry Profiling to fix it in record time.

Read more

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay