Javascript String Methods
Javascript String Methods
String Length
The length property returns the length of a string:
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript String Properties</h2>
<p>The length property returns the length of a string:</p>
<p id="demo"></p>
<script>
var txt = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var sln = txt.length;
document.getElementById("demo").innerHTML = sln;
</script>
</body>
</html>
The concat() Method
concat() joins two or more strings:
var text1 = "Hello";
var text2 = "World";
var text3 = text1.concat(" ", text2);
The concat() method can be used instead of the plus operator. These two lines do
the same:
var text = "Hello" + " " + "World!";
var text = "Hello".concat(" ", "World!");