JSFiddle - React, Tailwind, and code Playground
JavaScript
var str="The JavaScript slice() method for string.";
var n = '';
// Fetch first character of the string
n=str.slice(0,1);
alert(n); // OUTPUT: T
// fetch specific number of characters from string
n =str.slice(4,23);
alert(n); // OUTPUT: JavaScript slice()
// fetch specific number of characters starts from righthand side string
n =str.slice(-11,50);
alert(n); // OUTPUT: for string.