1+ var  abc  =  "abcdefghijklmnopqrstuvwxyz" ; 
2+ var  esc  =  'I don\'t \n know' ;  // \n new line 
3+ var  len  =  abc . length ;  // string length 
4+ abc . indexOf ( "lmno" ) ;  // find substring, -1 if doesn't contain  
5+ abc . lastIndexOf ( "lmno" ) ;  // last occurance 
6+ abc . slice ( 3 ,  6 ) ;  // cuts out "def", negative values count from behind 
7+ abc . replace ( "abc" , "123" ) ;  // find and replace, takes regular expressions 
8+ abc . toUpperCase ( ) ;  // convert to upper case 
9+ abc . toLowerCase ( ) ;  // convert to lower case 
10+ abc . concat ( " " ,  str2 ) ;  // abc + " " + str2 
11+ abc . charAt ( 2 ) ;  // character at index: "c" 
12+ abc [ 2 ] ;  // unsafe, abc[2] = "C" doesn't work 
13+ abc . charCodeAt ( 2 ) ;  // character code at index: "c" -> 99 
14+ abc . split ( "," ) ;  // splitting a string on commas gives an array 
15+ abc . split ( "" ) ;  // splitting on characters 
16+ 128. toString ( 16 ) ;  // number to hex(16), octal (8) or binary (2) 
17+ 18+ /* More Strings Methods */ 
19+ 20+ var  str  =  "Hello World" ; 
21+ var  str1  =  "United States of America" ; 
22+ var  str2  =  "states" ; 
23+ 24+ // Basics I 
25+ 26+ str . length  // Return length of string str 
27+ str [ n ]  // Return nth character of string str 
28+ str . charAt ( index )  // Return character in string str at specified index 
29+ str . toLowerCase ( )  // Convert string str to lower case 
30+ str . toUpperCase ( )  // Convert string str to upper case 
31+ 32+ // General I 
33+ 34+ str . indexOf ( substr )  // Return first index within string str of substring substr 
35+ str . split ( separator )  // Split string str into an array of substrings separated by param separator 
36+ str . trim ( )  // Trim whitespace from beginning and end of string str 
37+ str1  <  str2  // Return true if str1 is less than str2 
38+ str1  >  str2  // return true if str1 is greater than str2 
39+ 40+ // Experimental I 
41+ 42+ str . codePointAt ( index )  // Return non-negative int from string str that is the UTF-16 encoded code point at given index 
43+ str1 . includes ( str2 )  // Return true if str2 is found in string str1 
44+ str1 . endsWith ( str2 )  // Return true if string str1 ends with string str2 
45+ str . normalize ( )  // Return Unicode Normalization Form of string str 
46+ str . repeat ( int )  // Return string repeated int times of string str 
47+ str1 . startsWith ( str2 )  // Return true if string str1 starts with str2 
48+ str [ @@iterator ] ( )  // Return a new Iterator that iterates over the code points of string str, returning each code point as String value 
49+ 50+ // General II 
51+ 52+ str . charCodeAt ( index )  // Return number indicating Unicode value of char at given index of string str 
53+ str1 . concat ( str2 )  // Combine text of strings str1 and str2 and return a new string 
54+ str . lastIndexOf ( substr )  // Return last index within string str of substring substr 
55+ str . slice ( start ,  end )  // Extract a section of string str from start to end 
56+ str . substr ( start ,  length )  // Return characters in string str from start having length length 
57+ 58+ // General III 
59+ 60+ str . substring ( index1 ,  index2 )  // Return subset of string str between index1 and index2 
61+ str . toLocaleLowerCase ( )  //Convert chars in string str to lower case while respecting current locale 
62+ str . toLocaleUpperCase ( )  // Convert chars in string str to upper case while respecting current locale 
63+ str . trimLeft ( )  // Trim whitespace from left side of string st 
64+ str . trimRight ( )  // Trim whitespace form right side of string str 
65+ 66+ // General IV 
67+ 68+ str1 . localeCompare ( str2 )  // Return -1, 0, or 1 indicating if string str1 is less than, equal to, or greater than str2 
69+ str . match ( regexp )  // Match a regular expression regexp against string str 
70+ str1 . replace ( regexp ,  str2 )  // Replace matched regexp elements in string str1 with string str2 
71+ str . search ( regexp )  // Return position of search for a match between regexp and string str 
0 commit comments