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 1


1. What is JavaScript?

  • JavaScript is a scripting language that enables web developers/designers to build more functional and interactive websites.

  • Common uses of JavaScript include:

  • Alert messages

  • Popup windows

  • Dynamic dropdown menus

  • Form validation

  • Displaying date/time

  • JavaScript usually runs on the client-side (the browser's side), as opposed to server-side (on the web server). One benefit of doing this is performance. On the client side, JavaScript is loaded into the browser and can run as soon as it is called. Without running on the client side, the page would need to refresh each time you needed a script to run.


2. Difference between JavaScript and Java.?



JavaScript is Interpreted (not compiled) by client.

Java is compiled on server before execution on client.

JavaScript is Object-based. Code uses built-in, extensible objects, but no classes or inheritance.

Java is Object-oriented. Applets consist of object classes with inheritance.

In JavaScript, Code integrated with, and embedded in, HTML.

In JAVA, Applets distinct from HTML (accessed from HTML pages)

JavaScript execution is limited only to browser

JAVA code can be used for developing stand alone application or “applets” that can run on Internet

JavaScript can be executed on JavaScript enabled browser only.

JAVA application can be executed on any operating system i.e. Windows, MAC or Solaris

JavaScript doesn’t need to declare variable data type.

In JAVA data types must be declared.

JavaScript doesn’t need to declare variable data type.

In JAVA data types must be declared.

JavaScript can access browser objects

JAVA cannot access browser objects


3. What are the various datatypes in javascript?

  • A computer works with values. It manipulates values and produces some kind of result. Depending on the program, it may be limited as to what types of values it can work with. The types of values a program can work with are known as its data types.

  • Different types of datatypes are such as:

  • Number

  • String

  • Boolean

  • Function

  • Object

  • Null

  • Undefined

4. Difference between JavaScript and VBScript ?



Java Script is an object-oriented scripting language used to enable programmatic access to objects within both the client application and other applications.

VBScript is an Active Scripting language, which uses the component object Model to access elements of the environment within which it is running.

JavaScript is developed by Netscape

VBScript is developed by Microsoft

It is case sensitive

It is not case sensitive

JavaScript runs on any browser

VBScript runs only on IE

It uses curly braces to denote functions

It uses Function and End Function to denote functions

It uses the same character (+) for both addition and concatenation

It uses different character for different actions example: & for concatenation and + for addition

File extension for JavaScript is .js

File extension for VBScript is .vbs or .vba.


5. What does "1"+2+3 evaluate to?

  • Since 1 is a string, everything is a string, so the result is 123.

  • Here is the Example:



<title>cbtSAM JavaScript Example</title>



<script type="text/javascript">

var str = "1"+2+3

document.write("<br />After Evaluate the result is :" + str)




  • Output:

  • After Evaluate the result is: 123


6. How does 3+5+"8" evaluate to?

  • Since 3 and 5 are integers, this is number arithmetic, since 8 is a string, it’s concatenation, so 88 is the result.

  • You can see in the below example.



<title>cbtSAM JavaScript Example</title>



<script type="text/javascript">

var str = 3+5+"8";

document.write("<br />After Evaluate the result is: " + str)




  • Output:

  • After Evaluate the result is: 88


7. How do you submit a form using Javascript?

  • Use document.forms[0].submit();


8. How do you assign object properties?

  • obj["age"] = 27 or obj.age = 27.


9. What’s a way to append a value to an array?

  • arr[arr.length] = value;


10. What is the difference between an alert box and a confirmation box?

alert box

confirm box

An alert box is often used if you want to make sure information comes through to the user.

A confirm box is often used if you want the user to verify or accept something.

When an alert box pops up, the user will have to click "OK" to proceed.

When a confirm box pops up, the user will have to click either "OK" or "Cancel" to proceed.

If the user clicks "OK", the box returns true. If the user clicks "Cancel", the box returns false.


alert('Alert Message')


if (confirm('Select a button'))

alert('You selected OK')

else alert('You selected Cancel')

Pr.Pg border                                              Next Pg