Javascript Part 3: JavaScript Advanced 342
29. ERRORS AND EXCEPTIONS Javascript There are three types of errors in programming: (a) Syntax Errors, (b) Runtime Errors, and (c) Logical Errors. Syntax Errors Syntax errors, also called parsing errors, occur at compile time in traditional programming languages and at interpret time in JavaScript. For example, the following line causes a syntax error because it is missing a closing parenthesis. window.print(; When a syntax error occurs in JavaScript, only the code contained within the same thread as the syntax error is affected and the rest of the code in other threads gets executed assuming nothing in them depends on the code containing the error. Runtime Errors Runtime errors, also called exceptions, occur during execution (after compilation/interpretation). For example, the following line causes a runtime error because here the syntax is correct, but at runtime, it is trying to call a method that does not exist. window.printme(); Exceptions also affect the thread in which they occur, allowing other JavaScript threads to continue normal execution. 343
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
18. VOID KEYWORD Javascript void is
Javascript Click the followin
Javascript 2. If you do not want to
Javascript 104
Javascript Methods are useful for e
Javascript Output Book title is
Javascript User-defined objects /
Javascript In the following section
Javascript Click the following t
Javascript Day of the Month must be
Javascript alert("Value of bigNumbe
Javascript constructor It returns a
Javascript Try the following exampl
Javascript document.write(""); docu
Javascript document.write("num.toPr
Javascript Returns the primitive va
Javascript Returns the function tha
Javascript Method toSource() toStri
Javascript Output flag.toString
23. STRING Javascript The String ob
Javascript Try the following exampl
Javascript concat() indexOf() lastI
Javascript document.writeln("str.ch
Javascript Argument Details string2
Javascript lastIndexOf () This meth
Javascript var index = str1.localeC
Javascript substring. $n or $nn Whe
Javascript Search () This method ex
Javascript document.write( sliced )
Javascript Try the following exampl
Javascript Return Value Returns a s
Javascript JavaScript String toLow
Javascript var str = "Apples are r
Javascript were in a tag sup() Cau
Javascript blink () This method cau
Javascript Try the following exampl
Javascript JavaScript String font
Javascript JavaScript String link(
Javascript JavaScript String strik
Javascript JavaScript String sup(
Javascript input length prototype T
Javascript Prototype The prototype
Javascript push() reduce() reduceRi
Javascript every () Javascript arra
Javascript } var passed = [12, 5, 8
Javascript Array.prototype.filter =
Javascript } }; Example Try the fol
Javascript var len = this.length; v
Javascript join () Javascript array
Javascript var from = Number(argume
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(+