How To Use String Object Slice In JavaScript
In this article I am going to explain about String Object Slice In JavaScript.
Use slice() method in JavaScript
The slice() method is used to read the all character set and select the position of character set, and return a specified number of character.
This method use start and end parameter where we want to extract the string part.
The index will be start 0, like(0,1,2).
All browsers support string object slice() method.
Syntax
Example
<!DOCTYPE html>
<html>
<body style ="background-color :Red">
<p id="demo">Display the extractet part.</p>
<button onclick="myFunction()">Click here</button>
<script type="text/javascript">
function myFunction()
{
var str = "Welcome India!";
var n = str.slice(1, 6 );
document.getElementById("demo").innerHTML = n;
}
</script>
</body>
</html>
|
Output1

Output2
Further Readings
You may also want to read these related articles :here
Ask Your Question
Got a programming related question? You may want to post your question here
Programming Answers here