Javascript var index = str1.localeCompare( "XYZ" ); document.write("localeCompare first :" + index ); document.write("" ); var index = str1.localeCompare( "AbCD ?" ); document.write("localeCompare second :" + index ); Output localeCompare first :-1 localeCompare second :1 match () This method is used to retrieve the matches when matching a string against a regular expression. Syntax Use the following syntax to use the match() method. string.match ( param ) Argument Details param : A regular expression object. Return Value If the regular expression does not include the g flag, it returns the same result as regexp.exec(string). If the regular expression includes the g flag, the method returns an Array containing all the matches. Example Try the following example. 148
Javascript JavaScript String match() Method var str = "For more information, see Chapter 3.4.5.1"; var re = /(chapter \d+(\.\d)*)/i; var found = str.match( re ); document.write(found ); Output Chapter 3.4.5.1,Chapter 3.4.5.1,.1 replace () This method finds a match between a regular expression and a string, and replaces the matched substring with a new substring. The replacement string can include the following special replacement patterns: Pattern Inserts $$ Inserts a "$". $& Inserts the matched substring. $` Inserts the portion of the string that precedes the matched substring. $' Inserts the portion of the string that follows the matched 149
About the Tutorial JavaScript is a
Bitwise Operators .................
23. String ........................
setUTCDate () .....................
Checking for Plug-Ins .............
1. OVERVIEW Javascript What is Java
Javascript components, integrates w
Javascript This function can be use
Javascript The following example sh
Javascript JavaScript in Chrome Her
4. PLACEMENT Javascript There is a
Javascript This code will
5. VARIABLES Javascript JavaScript
Javascript Within the body of a fun
6. OPERATORS Javascript What is an
Javascript the right operand, if ye
Javascript Output (a == b) => false
Javascript Output (a && b) => fal
Javascript document.write("(a | b)
Javascript Ex: C /= A is equivalent
Javascript Set the variables to dif
Javascript Function Undefined Null
7. IF-ELSE Javascript While writing
Javascript Output Qualifies for dri
Javascript Try the following code t
Javascript Syntax The objective of
Javascript switch (grade) { case 'A
Javascript Syntax The syntax of whi
Javascript do{ Statement(s) to be e
10. FOR LOOP Javascript The for Loo
Javascript Current Count : 6 Curren
Javascript Set the variable to diff
Javascript Set the variable to
Javascript Entering the loop 2 3 4
Javascript Output Entering th
13. FUNCTIONS Javascript A function
Javascript Click the following butt
Javascript Click the following but
Javascript Use different parameters
Javascript var variablename = funct
14. EVENTS Javascript What is an Ev
Javascript ....... onmouseove
Javascript ondragenter script Trigg
Javascript onplaying script Trigger
15. COOKIES Javascript What are Coo
Javascript Enter name: Outp
Javascript Setting Cookies Expiry D
Javascript Output Enter Cookie Na
Javascript Example Try the followin
Javascript setTimeout('Redirect()',
17. DIALOG BOX Javascript JavaScrip
Javascript Output Click the fol
Javascript } var index = [12, 5, 8,
Javascript Array.prototype.map = fu
Javascript Its syntax is as follows
Javascript var rv = arguments[1]; }
Javascript } } throw new TypeError(
Javascript } rv = this[i--]; break;
Javascript } rv = fun.call(null, rv
Javascript Output Removed element
Javascript { } if (i in this && fun
Javascript Return Value Returns a s
Javascript toString () Javascript a
25. DATE Javascript The Date object
Javascript Return Value Returns the
Javascript Date Methods Here is a l
Javascript universal time. setUTCMo
Javascript Syntax Its syntax is as
Javascript Example Try the followin
Javascript var dt = new Date(); d
Javascript getMonth() : 11 getSecon
Javascript Syntax Its syntax is as
Javascript Try the following exampl
Javascript Output getUTCHours() :
Javascript Syntax Its syntax is as
Javascript JavaScript getYear Met
Javascript JavaScript setFullYear
Javascript If you specify a number
Javascript monthValue : An integ
Javascript setTime () Javascript da
Javascript Date.setUTCFullYear(year
Javascript document.write( dt );
Javascript Try the following exampl
Javascript Example Try the followin
Javascript var dt = new Date(1993,
Javascript toLocaleDateString () Ja
Javascript Syntax Its syntax is as
Javascript For instances of Date,
Javascript var dateobject = new
Javascript Output 743850547000 Date
Javascript minutes : An integer
Javascript In the following section
Javascript Example Try the followin
Javascript Property Value is : 0.43
Javascript JavaScript Math SQRT2 P
Javascript Try the following exampl
Javascript First Test Value : 3.141
Javascript JavaScript Math atan() M
Javascript var value = Math.atan2(+
Javascript Example Try the followin
Javascript Output First Test Value
Javascript var value = Math.log(10
Javascript min ( ) This method retu
Javascript var value = Math.pow(7,
Javascript Return Value Returns the
Javascript Output First Test Val
Javascript Example Try the followin
27. REGEXP Javascript A regular exp
Javascript Examples Following examp
Javascript m g Specifies that if th
Javascript Try the following exampl
Javascript Test1 - ignoreCase prope
Javascript if ( re.multiline ){ doc
Javascript exec ( ) The exec method
Javascript document.write("Test 2 -
Javascript document.write("Test 1 -
Javascript There are several DOMs i
Javascript forms[ ] 9 An array of F
Javascript Ex: document.close( ) op
Javascript This is main title Click
Javascript createElement( tagName)
Javascript NOTE: This example r
Javascript Specifies the loading st
Javascript NOTE: This example
Javascript Part 3: JavaScript Advan
Javascript Logical Errors Logic err
Javascript Now let us try to catch
Javascript Output Click the followi
Javascript Click the following to s
30. FORM VALIDATION Javascript Form
Javascript Basic Form Validation Fi
Javascript var emailID = document.m
Javascript Manual Animation So let'
Javascript } function moveRight(){
Javascript It is not possible to s
Javascript Output Checking for Plug
Javascript //--> If you
Javascript Error Messages in Firefo
Javascript Use a JavaScript Debugge
34. IMAGE MAP Javascript You can us
Javascript Output You can feel the
Javascript 6 plugins[] This propert
Javascript document.write(" Browser