String.An element is created in the DOM. It is created with a string—the browser resolves this string to an element name. Strings are everywhere.
String methods.We can build entire interfaces with just strings and logic. Many string methods are present. The most useful ones (like substring and indexOf) are often called.charAtcharCodeAtconcatfromCharCodeincludesindexOflastIndexOflengthlocaleCompareparseIntreplacesplitsubstringtoLowerCasetoUpperCase+ (concat)== (equal)=== (equal)!= (not equal)!== (not equal)
IndexOf.This method searches a string. We can specify a start location. We can use lastIndexOf to reverse the search of the string.indexOf
Equals.Two strings may be equal. With the "==" operator, a conversion may be done to test for equality. So a number may equal a string.Equals
Replace.Sometimes a string has parts we want to change to other values. With the replace method we modify the first occurrence of a string in a source string.replace
Split.Often we have a string that contains small delimiters (separator characters). We can split these strings apart with the split method.split
A review.Usually the lowest-level data type that fits is best: for numbers we prefer 100 (an integer) over "100." Strings have many conversion rules and useful properties like length.
Dot Net Perls
|© 2007-2019 Sam Allen. All rights reserved. Written by Sam Allen, firstname.lastname@example.org.|