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
If you liked this article, be sure to ❤️ it.
Top comments (0)