Gayathri Srinivasan edited untitled.tex  over 8 years ago

Commit id: c4f461f5efeecdad156cfcf1d697b2a37733ed67

deletions | additions      

       

\subsubsection{CharCodeAt():}  Returns the Unicode value of the character at position “n” within the string.  \\  \verb|//charAt(position)|  \\  \verb|var message="jquery4u"|  \\  \verb|//alerts "q"|  \\  \verb|alert(message.charAt(1))|  \subsubsection{Concat():}  Combines one or more strings (arguments v1, v2 etc) into the existing one and returns the combined string. Original string is not modified.  \\  \verb|//concat(v1, v2,..)|  \\  \verb|var message="Sam"|  \\  \verb|var final=message.concat(" is a"," hopeless romantic.")|  \\  \verb|//alerts "Sam is a hopeless romantic."|  \\  \verb|alert(final)|  \subsubsection{FromCharCode():}  Returns a string created by using the specified sequence of Unicode values (arguments n1, n2 etc). Method of String object, not String instance. For example: String.fromCharCode().  \\  \verb|//fromCharCode(c1, c2,...)|  \\  \verb|console.log(String.fromCharCode(97,99,98,120,121,122))|  \\  \verb|//output: abcxyz|  \\  \verb|console.log(String.fromCharCode(72,69,76,76,79))|  \\  \verb|//output: HELLO|  \subsubsection{Indexof():}  Searches and (if found) returns the index number of the searched character or substring within the string. If not found, -1 is returned. “Start” is an optional argument specifying the position within string to begin the search. Default is 0.  \\  \verb|//indexOf(char/substring)|  \\  \verb|var sentence="Hi, my name is Sam!"|  \\  \verb|if (sentence.indexOf("Sam")!=-1)|  \\  \verb|alert("Sam is in there!")|  \subsubsection{LastIndexof():}  Searches and (if found) returns the index number of the searched character or substring within the string. Searches the string from end to beginning. If not found, -1 is returned. “Start” is an optional argument specifying the position within string to begin the search. Default is string.length-1.  \\  \verb|//lastIndexOf(substr, [start])|  \\  \verb|var myString = 'javascript rox';|  \\  \verb|console.log(myString.lastIndexOf('r'));|  \\  \verb|//output: 11|  \subsubsection{Match():}  Executes a search for a match within a string based on a regular expression. It returns an array of information or null if no match is found.  \\  \verb|//match(regexp) //select integers only|  \\  \verb|var intRegex = /[0-9 -()+]+$/; |  \\  \verb|var myNumber = '999';|  \\  \verb|var myInt = myNumber.match(intRegex);|  \\  \verb|console.log(isInt);|  \\  \verb|//output: 999|  \\  \verb|var myString = '999 JS Coders';|  \\  \verb|var myInt = myString.match(intRegex);|  \\  \verb|console.log(isInt);|  \\  \verb|//output: null|  \subsubsection{Replace():}  Searches and replaces the regular expression (or sub string) portion (match) with the replaced text instead.  \\  \verb|//replace(substr, replacetext)|  \\  \verb|var myString = '999 JavaScript Coders';|  \\  \verb|console.log(myString.replace(/JavaScript/i, "jQuery"));|  \\  \verb|//output: 999 jQuery Coders|  \\  \verb|//replace(regexp, replacetext)|  \\  \verb|var myString = '999 JavaScript Coders';|  \\  \verb|console.log(myString.replace(new RegExp( "999", "gi" ), "The"));|  \\  \verb|//output: The JavaScript Coders|  \subsubsection{Search():}  Tests for a match in a string. It returns the index of the match, or -1 if not found.  \\  \verb|//replace(substr, replacetext)|  \\  \verb|var myString = '999 JavaScript Coders';|  \\  \verb|console.log(myString.replace(/JavaScript/i, "jQuery"));|  \\  \verb|//output: 999 jQuery Coders|  \\  \verb|//replace(regexp, replacetext)|  \\  \verb|var myString = '999 JavaScript Coders';|  \\  \verb|console.log(myString.replace(new RegExp( "999", "gi" ), "The"));|  \\  \verb|//output: The JavaScript Coders|  \subsubsection{Slice():}  Returns a substring of the string based on the “start” and “end” index arguments, NOT including the “end” index itself. “End” is optional, and if none is specified, the slice includes all characters from “start” to end of string.  \\  \verb|//slice(start, end)|  \\  \verb|var text="excellent"|  \\  \verb|text.slice(0,4) //returns "exce"|  \\  \verb|text.slice(2,4) //returns "ce"|  \subsubsection{Split():}  Splits a string into many according to the specified delimiter, and returns an array containing each element. The optional “limit” is an integer that lets you specify the maximum number of elements to return.  \\  \verb|//split(delimiter)|  \\  \verb|var message="Welcome to jQuery4u"|  \\  \verb|//word[0] contains "We"|  \\  \verb|//word[1] contains "lcome to jQuery4u"|  \\  \verb|var word=message.split("l")|  \subsubsection{SubString():}  Returns the characters in a string beginning at “start” and through the specified number of characters, “length”. “Length” is optional, and if omitted, up to the end of the string is assumed.  \\  \verb|//substring(from, [to])|  \\  \verb|var myString = 'javascript rox';|  \\  \verb|myString = myString.substring(0,10);|  \\  \verb|console.log(myString)|  \\  \verb|//output: javascript|  Returns the characters in a string between “from” and “to” indexes, NOT including “to” inself. “To” is optional, and if omitted, up to the end of the string is assumed.  \\  \verb|//substring(from, to)|  \\  \verb|var text="excellent"|  \\  \verb|text.substring(0,4) //returns "exce"|  \\  \verb|text.substring(2,4) //returns "ce"|  \subsubsection{Tolowercase():}  Returns the string with all of its characters converted to lowercase.  \\  \verb|//toLowerCase()|  \\  \verb|var myString = 'JAVASCRIPT ROX';|  \\  \verb|myString = myString.toLowerCase();|  \\  \verb|console.log(myString)|  \\  \verb|//output: javascript rox|  \subsubsection{Touppercase():}  Returns the string with all of its characters converted to uppercase.  \\  \verb|//toUpperCase()|  \\  \verb|var myString = 'javascript rox';|  \\  \verb|myString = myString.toUpperCase();|  \\  \verb|console.log(myString)|  \\  \verb|//output: JAVASCRIPT ROX|