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.
More Related Contents:
- Count the recurrence of a word
- Repeat a string in JavaScript a number of times
- Check if a JavaScript string is a URL
- How to check if a string contains text from an array of substrings in JavaScript?
- How to remove text from a string?
- How to replace all dots in a string using JavaScript
- How to convert a string to an integer in JavaScript?
- How can I convert a comma-separated string to an array?
- How to set object property (of object property of..) given its string name in JavaScript?
- Shorten string without cutting words in JavaScript
- How to find indices of all occurrences of one string in another in JavaScript?
- How can I insert a character after every n characters in javascript?
- How can I remove a character from a string using JavaScript?
- Javascript – return string between square brackets
- Case insensitive string replacement in JavaScript?
- JavaScript string with new line – but not using \n
- Remove characters from a string [duplicate]
- is the + operator less performant than StringBuffer.append()
- How to extract base URL from a string in JavaScript?
- Get the string representation of a DOM node
- How to convert text to binary code in JavaScript?
- How do I escape a string inside JavaScript code inside an onClick handler?
- Need a basename function in Javascript
- Remove a character at a certain position in a string – javascript [duplicate]
- Split a string based on multiple delimiters
- How to trim() white spaces from a string?
- Find difference between two strings in JavaScript
- Get object property name as a string
- Compare Strings Javascript Return %of Likely
- Does jQuery strip some html elements from a string when using .html()?