3

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

 2 years ago
source link: https://dev.to/iamatifriaz/js-tip-create-emoji-characters-in-javascript-using-string-fromcodepoint-20nh
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

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

Sep 16

・1 min read

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 modeExit 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 modeExit fullscreen mode

Initially created on Twitter

unknown tweet media content
Atif Riaz profile image
Atif Riaz
twitter logo
⚡JS Tip :
You can create emoji characters in JavaScript using String.fromCodePoint( );

Give it a try 🚀

#javascriptdeveloper #javascript
14:40 PM - 14 Sep 2021

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


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK