Course Banner


String in JavaScript

String predefined of Javascript used for storing the text data inside any variable.
Example
var movie="My Name is Khan";
You can access each character in a string with its position
Example
var character= movie [7];
STRING LENGTH
<!DOCTYPE html>
<html>
<body>
<script>
var txt = "Learning JavaScript is easy";
document.write("<p>" + txt.length + "</p>");
var txt="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
document.write("<p>" + txt.length + "</p>");
</script>
</body>
</html>