1. Java Script Module 2. World Wide Web (WWW) 3. Web Terms 4. NEED FOR SCRIPT 5. Introduction to Internet Programming 6. CLIENT SIDE and SERVER SIDE Scripting 7. Different Scripting Languages 8. Introduction to JavaScript 9. JavaScript and Security 10. How to Enable JavaScript 11. Advantages of Java Script 12. Limitations with JavaScript 13. Difference between JavaScript and JAVA 14. Difference between JavaScript and VBScript 15. JavaScript Development Tools 16. JavaScript Programming Techniques 17. JavaScript terms 18. Starting with JavaScript Programming step by step 19. Time to start JavaScript Programming 20. JavaScript Variables 21. JavaScript RESERVED WORDS 22. JavaScript Data Type 23. NUMBER DATA TYPE 24. BOOLEAN DATA TYPE 25. STRING DATA TYPE 26. NULL DATA TYPE 27. JavaScript Undefined DATA TYPE 28. JavaScript Operators 29. JavaScript Arithmetic Operators 30. JavaScript Logical Operators 31. JavaScript Comparison Operators 32. JavaScript String Operators 33. Bit Manipulation Operators 34. JavaScript Assignment Operators 35. JavaScript Conditional Operator 36. Conversion between JavaScript Data Types 37. Alert JavaScript function 38. confirm JavaScript function 39. prompt JavaScript function 40. JavaScript Statements 41. Single line & Multi-line Comments 42. JavaScrip If Statement 43. JavaScript if..else Statements 44. JavaScript If…else..if statement. 45. JavaScript For Statement 46. JavaScript Statement: 47. JavaScript While Statement 48. JavaScript do while Statement: 49. JavaScript break and continue statement 50. JavaScript switch Statement: 51. JavaScript function() 52. JavaScript function with a Return Value 53. JavaScript with Statement 54. try, catch, and throw Statements 55. JavaScript ARRAY 56. JavaScript array of different data types 57. JavaScript ARRAY and Bubble sorting Program 58. JavaScript Array Methods 59. concate() method 60. every() method 61. filter() method 62. forEach() method 63. indexOf() method 64. Join() method 65. lastIndexOf() method 66. map() method 67. reduce() method 68. reduceRight() method 69. reverse() method 70. some() method 71. toSource() method 72. toString() method 73. pop() method 74. push() method 75. shift () method 76. slice () method 77. splice () method 78. sort() method 79. unshift() method 80. EVENT handling with JavaScript 81. onblur JavaScript Event 82. onchange JavaScript Event 83. onclick JavaScript Event 84. onDblClick JavaScript Event 85. onfocus JavaScript Event 86. onkeydown JavaScript Event 87. onkeyup JavaScript Event 88. Onkeypress JavaScript Event 89. onLoad JavaScript Event 90. onMousedown JavaScript Event 91. onMouseup JavaScript Event 92. Onmouseover JavaScript Event 93. onmouseout JavaScript Event 94. onMouseMove JavaScript Event 95. onReset JavaScript Event 96. onsubmit JavaScript Event 97. onUnload JavaScript Event 98. The Screen Object 99. JavaScript Interview Part1 100. JavaScript Interview Part2 101. JavaScript Interview Part3 102. JavaScript Interview Part4 103. JavaScript Interview Part5 104. JavaScript Interview Part6 105. JavaScript Interview Part7 106. JavaScript Interview Part8 107. JavaScript Interview Part9 108. JavaScript Interview Part10
Pr.Pg border                                             

JavaScript Interview Questions and Answers Part 10


91. What is Shift() method in Javascript?

  • The shift() method is similar as the pop() method but the difference is that Shift method works at the beginning of the array.

  • The shift() method take the first element off of the given array and returns it. The array on which is called is then altered.

  • For example

<script type="text/javascript">

var element = [25, 5, 10, 15].shift();

document.write("Removed number is : " + element );


  • Output:

  • Removed number is: 25

  • When we call shift() on an empty array, it will return an undefined value.


92. What is Event Handling in JavaScript?

  • Events are the mechanism, by which the browser responds, to the user actions. Events can be expressed as any action from user or any activity related with browser.

  • For example, when a user clicks a hyperlink or a button, or enters data in a form, an event is generated informing the browser that an action has occurred and that further processing is required.

  • The browser waits for events to occur, and when they do, it performs whatever processing is assigned to those events. The processing that is performed in response to the occurrence of an event is known as event handling. The code that performs this processing is called an event handler.

  • Following are some of the things that can be undertaken with help of HTML and JavaScript.

  • Display Message in case of some events

  • Flash Alert message in case of some events

  • Validate data entry form

  • Perform Calculations and display result.

  • Load / Display animation in response to some event

  • Interact with java Applet and other Plug-ins.

93. What is the difference between script type and the script language attributes?

  • The script type specifies the type of content that is used to show the language used by the browsers like “language=text/javascript”.

  • This defines the MIME type that is also known as Multipurpose Internet Mail Extensions (MIME). Text in this defines a plain text format and script defines the language that will be used.

  • The script language attribute on the other hand specify a particular version of JavaScript language that is required to run the script and to provide a mechanism to fall back if any browser doesn't support it.

  • Script type is used to define the type through which the browser can understand the language and all the compatible browsers can execute the type according to themselves, whereas the script language attribute defines the content and its attributes that are used



94. What is the difference between Scripting and Programming?



Scripting is easier to write than programming.

As programming requires more hands on to the code and a language specification to write

Scripting consists of lots of tools to easily create an object model and run it using any browser

Wheras programming doesn't have many tools to create an object model and it is not easy to use browser compatibility

Scripts work with more than just objects, each statement of the JavaScript does something means perform some actions,

Whereas programming becomes different as each and every action takes time to execute

Scriptting doesn't require lots of knowledge to be provided with and can be easily learnt

But to learn a programming language it requires lots of knowledge.



95. What are the different types of errors supported by JavaScript?

  • There are many errors that can occur in a system. JavaScript provides a message for all the errors at run time and dynamically generate the error code. The errors that are present:

  • Load-time errors: these are the errors that come when loading a web page like using of improper syntax and the errors gets detected the moment user loads a page.

  • Run-time errors: These are the error that comes due to misuse of the language commands used inside the HTML document. This shows that it has loaded but the functionality is not properly integrated.

  • Logic errors: these are the errors that come due to bad logic performed on a function that is having different operation but it is made to have logic differently.


96. What is Cookies in JavaScript ?

  • A cookie is nothing but a small text file that's stored in your browser. It contains some data:

  • Name: Cookies are set and retrieved in the form of key and value pairs.

  • Expiry Date: The date the cookie will expire. If this is blank, the cookie will expire when the visitor quits the browser.

  • Domain: The domain name of your site.

  • Path: The path to the directory or web page that set the cookie. This may be blank if you want to retrieve the cookie from any directory or page.

  • Secure: If this field contains the word "secure" then the cookie may only be retrieved with a secure server. If this field is blank, no such restriction exists.

  • JavaScript can also manipulate cookies using the cookie property of the Document object. JavaScript can read, create, modify, and delete the cookie or cookies that apply to the current web page.


97. What is Navigator Object in JavaScript?

  • The navigator object provides information about the type and version of the browser that is used to run HTML program.

  • Careful use of Navigator objects gives developers idea to determine the capabilities of user’s browser, and according to the capabilities the developer can guide them to appropriate code.

  • Some importatant properties of Navigator object is:

  • appCodeName: Specifies the code name of the browser.

  • appName: Specifies the name of the browser

  • appVersion: Specifies version information for the Navigator 


98. What is Window Object in JavaScript?

  • The Window object is basic to all browser script. The Window object is a Top Level object that is automatically defined by browser. A separate window object is defined for each window that is opened.

  • The window object is so important to writing browser scripts that the current window object is assumed by default in many cases and may be omitted.

  • For example, when you use the statement document.write (“write this text to the current window.”) In a script, JavaScript assumes that you are referring to the Current window object and executes the following statement. window.document.write(“Write this text to the current window.”)


99. What is Location Object in JavaScript ?

  • The location object contains information about the current URL.

  • The location object is part of the window object and is accessed through the window.location property.

  • The location object represents the URL loaded in a window and, as an added bonus, it also parses the URL into various segments:

  • hash — If the URL contains a pound sign (#), this returns the content after it (for example, has a hash equal to “#section1”).

  • host — The name of the server (for example,

  • hostname — Most often equal to host, this sometimes eliminates the www. from the front.

  • href — The full URL of the currently loaded page

  • pathname — Everything after the host in the URL. For example, the pathname for is “/pictures/index.htm”.

  • port — The port of the request if specified in the URL. By default, most URLs don’t include the port as part of the URL so this property is typically blank.

  • If a URL is used such as, the port is equal to 8080.

  • protocol — The protocol used in the URL. This is everything before the two forward slashes (//) in the URL.

  • For example, the protocol for is http: and the protocol for is ftp:.

  • search — Otherwise known as the query string, this is everything after a question mark (?) in a URL performing a GET request.

  • For example, the search for http://www.somewhere .com/search.htm?term=javascript is ?term=javascript