first x characters of string javascript code example
Example 1: str.substring if 2 letters
public String firstTwo(String str) {
return str.length() < 2 ? str : str.substring(0, 2);
}
Example 2: reactjs cut part of string
var str = "Hello world!";
var res = str.substring(1, 4);
// res value is "ell"