DEV Community

Atif Riaz
Atif Riaz

Posted on

⚡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}!`;
// output: "I got you 😄!" 

Enter fullscreen mode Exit fullscreen mode

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


Here is the syntax:

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.

Top comments (0)