Search notes:

JavaScript: String object

Methods and properties

prototype.at()
fromCharCode()
fromCodePoint()
length
prototype.charAt()
prototype.charCodeAt()
prototype.codePointAt()
prototype.concat()
prototype.endsWith()
prototype.includes()
prototype.indexOf()
prototype.lastIndexOf()
prototype.localeCompare()
prototype.match()
prototype.matchAll()
prototype.normalize()
prototype.padEnd()
prototype.padStart()
prototype.repeat()
prototype.replace()
prototype.replaceAll()
prototype.search()
prototype.slice() Returns a substring from a string. Compare with the slice() method of the Array object.
prototype.split()
prototype.startsWith()
prototype.substr() Deprecated
prototype.substring()
prototype.toLocaleLowerCase()
prototype.toLocaleUpperCase()
prototype.toLowerCase()
prototype.toString()
prototype.toUpperCase()
prototype.trim()
prototype.trimEnd()
prototype.trimStart()
prototype.valueOf()
prototype[@@iterator]()
raw()
The following wrapper embed the string into the corresponding representation of an HTML elements. Thes functions are deprecated:

charAt

<!DOCTYPE html>
<html>
<head>
  <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
  <title>String.charAt</title>

  <script type="text/javascript">
    
    function main() {

      var out = document.getElementById('out');

                   //  012345679
      out.innerHTML = "abcdefghi".charAt(5);  // f
      
    }

  </script>

</head>
<body onload='main()';>
  <div id='out'></div> 
</body>
</html>
Github repository about-javascript, path: /objects/String/charAt.html

slice

slice() returns a substring from a string.
str.slice(from);
str.slice(from, to);
from and to can be negative numbers in which case they're counted from the end of the string.

toUpperCase

Convert a string to upper case.
<!DOCTYPE html>
<html>
<head>
  <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
  <title>String.toUpperCase()</title>

  <script type="text/javascript">
    
    function main() {
    
      var out = document.getElementById('out');

      out.innerHTML = "foo bar baz".toUpperCase();

    }

  </script>

</head>
<body onload='main()';>
  <div id="out"></div>
</body>
</html>
Github repository about-javascript, path: /objects/String/toUpperCase.html

fromCharCode

String.fromCharCode creates a string from one ore more Unicode codepoints, see here.

determineType

<!DOCTYPE html>
<html>
<head>
  <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
  <title>Determine type of String instance</title>

  <script type="text/javascript">
    
    function main() {
      str = 'Hello world';

      document.getElementById('type').innerHTML = Object.prototype.toString.call(str);

    }

  </script>

</head>
<body onload='main()';>

  The »type« of <code>'Hello world'</code> is: <code><span id='type'></span></code>

</body>
</html>
Github repository about-javascript, path: /objects/String/determineType.html

See also

Methods that operate on regular expressions.
Creating multi line strings with template literals.
String functions for regular expressions
parseInt to create an integer from a String.
Javascript code snippets
objects

Index