get character from string js code example

Example 1: javascript get character from string

// (ES6 / ES2015)+ way of doing it
const str = "Hello World!";
const chars = [...str];

// Pre-ES2015 way of doing it
var chars2 = str.split("");

Example 2: javascript get first character of string

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

Example 3: javascript last character of string

var lastChar = myString[myString.length -1];

Example 4: javascript get character from string

const str = "Hello World";
const firstCharacter = str.charAt(0);

Example 5: javascript string return character

var str = "HELLO WORLD";
var res = str.charAt(0);