Use the limit parameter: - Javascript String

Javascript examples for String:split

Description

Use the limit parameter:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {//from ww w. j a  v a 2 s  .c  om
    var str = "The following code shows how to ?";
    var res = str.split(" ", 3);
    document.getElementById("demo").innerHTML = res;
}
</script>

</body>
</html>

Related Tutorials