Knowledge Walls
Ammu
Hyderabad, Andhra Pradesh, India
Passcode:
String in Examples of Javascript 1
1509 Views
Standards 
Code Result
\b Backspace
\f Form Feed
\n New Line
\r Carriage Return
\t Horizontal Tabulator
\v Vertical Tabulator
Code Result Description
\' ' Single quote
\" " Double quote
\\ \ Backslash

substring() is similar to slice().

The difference is that substring() cannot accept negative indexes.
 

substr() is similar to slice().

The difference is that the second parameter specifies the length of the extracted part.

Examples 
<!DOCTYPE html>
    <html lang="en-US">
        <head>
            <meta charset="UTF-8">
            <title>string</title>
        </head>
        <body>
            
            <script>
              var name=" vidhyaa";
              name=name.trim();
              document.write(name.length+"<br>");//return the length of the string.
              document.write(name.toUpperCase()+"<br>");
              document.write(name.toLowerCase()+"<br>");
              document.write(name.concat("laya")+"<br>"); 
              document.write(name.charAt(2)+"<br>");
              document.write(name.substring(2,5)+"<br>");
              document.write(name.slice(-3,-1)+"<br>");
              document.write(name.substr(-3,1)+"<br>");
              document.write(name.indexOf("d")+"<br>");// returns -1 not exist otherwise index of the first occurrance. index starts with zero.
              document.write(name.lastIndexOf("a")+"<br>");// searching string from reverse.
            </script>
            
        </body>
    </html>
Next Topics
Next lessons of current book.
Examples of Javascript 1
Examples of Javascript 1
Examples of Javascript 1
Examples of Javascript 1
Previous Topics
Previous lessons of current book.
Examples of Javascript 1
Examples of Javascript 1
Examples of Javascript 1
Best Lessons of "Javascript 1"
Top lessons which are viewed more times.
Examples of Javascript 1
Examples of Javascript 1
Examples of Javascript 1
Examples of Javascript 1
Examples of Javascript 1
Examples of Javascript 1
  Copyright © 2014 Knowledge walls, All rights reserved
KnowledgeWalls
keep your tutorials and learnings with KnowledgeWalls. Don't lose your learnings hereafter. Save and revise it whenever required.
Click here for more details