string to char javascript code example

Example 1: javascript get first character of string

var str="Hello Folks!"
var firstStringChar = str.charAt(0); //H

Example 2: javascript unicode to string

//convert unicode to string

// using a variable
let unicodeString = "http\\u00253A\\u00252F\\u00252Fexample.com\u{1F4A9}\x61";
console.log(decodeURIComponent(JSON.parse('"' + unicodeString.replace(/\"/g, '\\"') + '"')));

// direct approach
console.log(decodeURIComponent(JSON.parse('"http\\u00253A\\u00252F\\u00252Fexample.com\u{1F4A9}\x61"')));

Tags:

Php Example