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 Next Pg

JavaScript Interview Questions and Answers Part 5


41. What are undefined and undeclared variables?

  • Undeclared variables are those that are not declared in the program (do not exist at all),trying to read their values gives runtime error.But if undeclared variables are assigned then implicit declaration is done .

  • Undefined variables are those that are not assigned any value but are declared in the program.Trying to read such variables gives special value called undefined value.


42. What is === operator ?

  • === is strict equality operator, it returns true only when the two operands are having the same value without any type conversion.

  • Here is the example of strictly operator:




<title> cbtSAM Javascript Example</title>



<script language="javascript">

var a = "5"

var b = 5


if(a === b)


document.write(" Assigned variables are not strictly equals ")




document.write(" Assigned variables are not strictly equals ")





  • Output:

  • Assigned variables are not strictly equals


43. How to disable an HTML object ?

document.getElementById("myObject").disabled = true;


44. How to create a popup warning box?

alert('Warning: Enter warning message !.');


45. How to create a confirmation box?

confirm("Do you really want to close?");


46. How to create an input box?

  • The JavaScript prompt box prompts the user to input text. The 'prompt' box is created using JavaScript's built-in prompt() function.

  • When the JavaScript prompt() function is triggered, a small box will pop up and display a message to the user (supplied by you), a text field (for the user's input), an "OK" button, and a "Cancel" button.

  • If the user clicks "OK" the box returns the input value. If the user clicks "Cancel" the box returns null.



General syntax of prompt box is as follows:

propmpt (“textmessage”,”default_value”)




<title>cbtSAM Javascript prompt box example</title>



<script type="text/javascript">

name = prompt ("Enter the Company Name","cbtSAM")





47. How to force a page to go to another page using JavaScript ?

<script language="JavaScript" type="text/javascript" >

<!-- location.href=""; //-->



48. What's Math Constants and Functions using JavaScript?

  • JavaScript’s Math object provides many arithmetic and trigonometric functions. Most of these are functions you probably already know.

  • These functions expand the mathematical ability of JavaScript beyond the basic arithmetic operators.

  • JavaScript’s Math object is a static object, so you won’t need to Instantiate it. Its properties are actually basic constants, such as pi (_) and the square root of 2.

  • Its methods are mathematical functions, such as pow()(power), sin(), cos(), and others. These methods and properties are encapsulated in an object because objects are meant to be entities constructed of related data and functions.

  • To access elements of the Math object, you do not need to create an instance. You access them via messages sent directly by the Math object itself.

  • For example, the PI constant is a property of the Math object, and can be accessed via the following syntax:

var pi = Math.PI

Math.abs(value); //absolute value

Math.max(value1, value2); //find the largest

Math.random() //generate a decimal number between 0 and 1

Math.floor(Math.random()*101) //generate a decimal number between 0 and 100


49. What does the delete operator do?

  • The delete operator is used to delete all the variables and objects used in the program ,but it does not delete variables declared with var keyword.


50. How to get value from a textbox?


Pr.Pg border                                              Next Pg