Separate each character, including white-space: - Javascript String

Javascript examples for String:split

Description

Separate each character, including white-space:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

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

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

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

</body>
</html>

Related Tutorials