Javascript How to get first three characters of a string

var str="012123";
var strFirstThree = str.substring(0,3);

console.log(str); //shows '012123'
console.log(strFirstThree); // shows '012'

Now you have access to both.

Leave a Comment