This content originally appeared on DEV Community and was authored by DEV Community
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 ?!"
Syntax
Here is the syntax:
String.fromCodePoint(num1)
String.fromCodePoint(num1, num2)
String.fromCodePoint(num1, num2, ..., numN)
Initially created on Twitter
⚡JS Tip :
You can create emoji characters in JavaScript using String.fromCodePoint( );
Give it a try ?
#javascriptdeveloper #javascript14:40 PM - 14 Sep 2021
If you liked this article, be sure to ❤️ it.
This content originally appeared on DEV Community and was authored by DEV Community
DEV Community | Sciencx (2021-09-16T11:51:00+00:00) ⚡JS Tip: Create Emoji Characters in JavaScript using String.fromCodePoint();. Retrieved from https://www.scien.cx/2021/09/16/%e2%9a%a1js-tip-create-emoji-characters-in-javascript-using-string-fromcodepoint/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.