⚡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);…


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 ?!" 


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)

Initially created on Twitter

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


This content originally appeared on DEV Community and was authored by DEV Community


Print Share Comment Cite Upload Translate Updates
APA

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/

MLA
" » ⚡JS Tip: Create Emoji Characters in JavaScript using String.fromCodePoint();." DEV Community | Sciencx - Thursday September 16, 2021, https://www.scien.cx/2021/09/16/%e2%9a%a1js-tip-create-emoji-characters-in-javascript-using-string-fromcodepoint/
HARVARD
DEV Community | Sciencx Thursday September 16, 2021 » ⚡JS Tip: Create Emoji Characters in JavaScript using String.fromCodePoint();., viewed ,<https://www.scien.cx/2021/09/16/%e2%9a%a1js-tip-create-emoji-characters-in-javascript-using-string-fromcodepoint/>
VANCOUVER
DEV Community | Sciencx - » ⚡JS Tip: Create Emoji Characters in JavaScript using String.fromCodePoint();. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/09/16/%e2%9a%a1js-tip-create-emoji-characters-in-javascript-using-string-fromcodepoint/
CHICAGO
" » ⚡JS Tip: Create Emoji Characters in JavaScript using String.fromCodePoint();." DEV Community | Sciencx - Accessed . https://www.scien.cx/2021/09/16/%e2%9a%a1js-tip-create-emoji-characters-in-javascript-using-string-fromcodepoint/
IEEE
" » ⚡JS Tip: Create Emoji Characters in JavaScript using String.fromCodePoint();." DEV Community | Sciencx [Online]. Available: https://www.scien.cx/2021/09/16/%e2%9a%a1js-tip-create-emoji-characters-in-javascript-using-string-fromcodepoint/. [Accessed: ]
rf:citation
» ⚡JS Tip: Create Emoji Characters in JavaScript using String.fromCodePoint(); | DEV Community | Sciencx | 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.

You must be logged in to translate posts. Please log in or register.