JavaScript Interview Questions You'll Most Likely Be Asked
JavaScript Interview Questions You'll Most Likely Be Asked
Questions
Review these typical interview questions and think about how you would
answer them. Read the answers listed; you will find best possible answers
along with strategies and suggestions.
This page is intentionally left blank
Chapter 1
Introduction to JavaScript
1: What is JavaScript?
Answer:
JavaScript is a scripting language that adds interactivity to HTML
pages.
11: Why are comments used in JavaScript and how are they
inserted?
Answer:
Usually comments are added to make the code more readable but
they can also be used to explain the code. They are inserted with //
(for single line comments) and /* */ for multiple lines comments.
13: What does a variable of var y=10; and var catname= "Tomcat";
do?
Answer:
With the execution of the above code, we have variables that hold
values of 10(for y) and Tomcat (for catname).
Note that the inclusion of text warrants " " being used.
Example:
var count=100;
typeof count;
var status;
document.writ
Pattern_Match:First,First
22: Which property is used to match the pattern at the start of the
string?
Answer:
ol is used for position matching.
Example:
//Pattern_Match:First First_Regular
23: Which property is used to match the pattern at the end of the
string?
Answer:
Example:
//Pattern_Match:First Expression_First
This page is intentionally left blank
Chapter 3
24: What are operators? Which are the most important operators
in JavaScript?
Answer:
Operators in JavaScript are used to combine values that form
expressions. The most important are: = and +. The first is used to
assign values and the second one is used to add values together.
27: Does creating an alert box prompt the user to respond with
OK or Cancel?
Answer:
No. An alert box only gives the user the option of choosing OK to
proceed.
28: What are functions in JavaScript and where are they placed?
Answer:
Functions contain code that is executed before an event thus
stopping the browser from loading a script when the page opens.
Functions can be placed both in the <head> or <body> section, but
it is advised to place them in the <head> section.