HI WELCOME TO SIRIS

JavaScript String Functions

In JavaScript following string function is use for different operation. If you want to count the string length use str.length function etc. Also String is transfer to Uppercase or Lowercase and change the style of string and more string functions.

Count the length of a string

Example
<!DOCTYPE html>
<html lang="en">
<head>
  <title>JavaScript str length function</title>
</head>
<body>
  <script type="text/javascript">
    var str = "Hello String!";
    document.write('Length of the given String: ' + str.length);
  </script>
</body>
</html>

Example Result

String toLowerCase() and toUpperCase()

Example
<!DOCTYPE html>
<html lang="en">
<head>
  <title>JavaScript String toLowerCase() and toUpperCase() function</title>
</head>
<body>
  <script type="text/javascript">
    var str = "Hello String";
    document.write(str.toUpperCase() + "<br />");
    document.write(str.toLowerCase());
  </script>
</body>
</html>

Example Result

JavaScript String Format functions

Example
<!DOCTYPE html>
<html lang="en">
<head>
  <title>JavaScript string function</title>
</head>
<body>
  <script type="text/javascript">
    var str = "Hello String!";
    document.write("<p> Bold: " + str.bold() + "</p>");
    document.write("<p> Italic: " + str.italics() + "</p>");
    document.write("<p> Big: " + str.big() + "</p>");
    document.write("<p> Small: " + str.small() + "</p>");
    document.write("<p> Strike: " + str.strike() + "</p>");
    document.write("<p> Fontsize: " + str.fontsize(4) + "</p>");
    document.write("<p> Fontcolor: " + str.fontcolor("orange") + "</p>");
    document.write("<p> Link:"+str.link("http://Way2Tutorial.com")+"</p>");
    document.write("<p> Subscript: " + str.sub() + "</p>");
    document.write("<p> Superscript: " + str.sup() + "</p>");
  </script>
</body>
</html>

Example Result