The String.fromCharCode()
method in JavaScript is used to create a string from a sequence of Unicode code points. This method takes one or more Unicode code point values as arguments, and returns a new string that is the result of converting each code point value to a character.
Here is an example of how the String.fromCharCode()
method works:
const result = String.fromCharCode(72, 101, 108, 108, 111);
console.log(result);
// the result will be: 'Hello'
In the code example above, we use the String.fromCharCode()
method to create a string from a sequence of Unicode code point values. The String.fromCharCode()
method takes one or more code point values as arguments, and returns a new string that is the result of converting each code point value to a character. In this case, we pass in the code point values for the letters H
, e
, l
, l
, and o
as the arguments to the String.fromCharCode()
method.
As a result of calling the String.fromCharCode()
method, the result
variable will be set to 'Hello'
, which is the string created by converting the code point values to characters.
Leave a Reply