Skip to Content

JavaScript Interview Questions and Answers - JavaScript Quiz

Here is a collection of 77 commonly asked JavaScript Interview Questions along with their answers. These JavaScript questions are most frequently asked during Interviews. These questions will not only test your knowledge of JavaScript but also help you prepare for the interview of a JavaScript developer.

JavaScript Interview Questions and Answers

This is an interactive multiple-choice JavaScript quiz that allows you to test your knowledge of JavaScript by answering the following questions. Answers are given at the end of all questions.

1) What is the output of following JavaScript code?

a) 44
b) 8
c) 4
d) Error output

2) What is the output of following JavaScript code?

a) Chadha
b) C,h,a,d,h,a,S,o,f,t,w,a,r,e,T,e,c,h,n,o,l,o,g,i,e,s
c) Chadha,Software,Technologies
d) Chadha Software Technologies

3) Is it possible to nest functions in JavaScript?

a) True
b) False

4) What is the output of following JavaScript code?

a) get code name of the browser of a visitor
b) set code name of the browser of a visitor
c) None of the above

5) Which of the following is true?

a) If onKeyDown returns false, the key-press event is cancelled.
b) If onKeyPress returns false, the key-down event is cancelled.
c) If onKeyDown returns false, the key-up event is cancelled.
d) If onKeyPress returns false, the key-up event is canceled.

6) Scripting language is

a) High Level Programming language
b) Assembly Level programming language
c) Machine level programming language

7) Which best explains getSelection()?

a) Returns the VALUE of a selected OPTION.
b) Returns document.URL of the window in focus.
c) Returns the value of cursor-selected text
d) Returns the VALUE of a checked radio input.

8) What is the output of following JavaScript code?

a) Good %
b) 1,0,0
c) G,o,o,d,%
d) Error

9) What is the output of following JavaScript code?

a) P
b) E
c) S
d) Error

10) Choose the client-side JavaScript object:

a) Database
b) Cursor
c) Client
d) FileUpLoad

11) Are Java and JavaScript the same?

a) No
b) Yes

12) Syntax for creating a RegExp object:

(A) var txt=new RegExp(pattern,attributes);
(B) var txt=/pattern/attributes;

Which of the above mentioned syntax is correct?

a) (A) only
b) (B) only
c) Both (A) and (B)
d) None of the above

13) What is the output of following JavaScript code?

a) Error
b) 2
c) 1
d) 3

14) What is meant by "this" keyword in JavaScript?

a) It refers current object
b) It referes previous object
c) It is variable which contains value
d) None of the above

15) In JavaScript, Window.prompt() method returns true or false value?

a) False
b) True
c) None of above

16) Math. round(-20.51) = ?

a) 20
b) -21
c) 19
d) None

17) What is the output of following JavaScript code?

a) %,!,{,[,!,!
b) Q,u,a,l,i,t,y,1,0,0
c) Quality 100
d) Error

18) What is the output of following JavaScript code?

a) Error
b) Chadha Software Technologies
c) Web Development
d) Web Developmnet,Application Development,Testing,Chadha Software Technologies

19) Choose the server-side JavaScript object among the following:

a) FileUpLoad
b) Function
c) File
d) Date

20) What does parseFloat(9+10) evaluates to in JavaScript?

a) 19
b) 910
c) None

21) What is the output of following JavaScript code?

a) 258
b) Error
c) 7
d) 78

22) Which keyword is used to declare variables in JavaScript?

a) Var
b) Dim
c) String

23) In JavaScript, which of the following method is used to evaluate the regular expression?

a) eval(2*(3+5))
b) evaluate(2*(3+5))
c) evalu(2*(3+5))
d) None of the above

24) What is the output of following JavaScript code?

a) 100
b) 1,0,0
c) q,u,a,l,i,t,y,%
d) Error

25) What is the output of following JavaScript code?

a) hello
b) bye
c) Error in string handling
d) None of the above

26) What is the output of following JavaScript code?

a) Error
b) SOFTWARE
c) Software
d) null

27) How do you create a new object in JavaScript?

a) var obj = {};
b) var obj = Object();
c) var obj=new {};
d) None of the above

28) What does isNaN function do in JavaScript?

a) Return true if the argument is not a number.
b) Return false if the argument is not a number.
c) Return true if the argument is a number.
d) None of the above

29) If x=103 & y=9 then x%=y , what is the value of x after executing x%=y?

a) 4
b) 3
c) 2
d) 5

30) Choose the external object among the follwing:

a) Date
b) Option
c) Layer
d) Checkbox

31) Choose the four symbol pairs that represent RegExp properties lastMatch, lastParent, leftContext, and rightContext, respectively:

a) $&, $+, $`, $’
b) $+, $&, $’, $`
c) $&, $~, $`, $’
d) $+, $&, $`, $’

32) Which of the following properties hold the values of the pixels of the length of the width and height of the viewer’s screen resolution?

a) screen.width and screen.height
b) Resolution.width and Resolution.height
c) screen.pixels.width and screen.pixels.height
d) ViewerScreen.width and ViewerScreen.height

33) What does ParseInt("15",10) evaluates to?

a) 15
b) 10
c) 151
d) 150

34) Which JavaScript feature uses JAR files?

a) Object signing
b) Style sheets
c) Netcaster channels
d) Image rollovers

35) How to assign a function to a variable with the JavaScript Function contructor?

a) var f=Function("x","y","return x+y");
b) var f=Function(x,y){ return x+y;}
c) var f= new Function("x", "y", "return x + y");

36) In JavaScript, Window.alert() is used to allow user to enter something

a) True
b) False
c) None of above

37) What is the output of following JavaScript code?

document.write(pattern.exec(cst) + " ");
document.write(pattern.exec(cst) + " ");
document.write(pattern.exec(cst) + " ");
}

a) in in In
b) in in in
c) in in null
d) in null null

38) Does JavaScript has any DATE data type?

a) Yes
b) No

39) Math.round(-20.5)=?

a) -21
b) 20
c) -20
d) 21

40) Is _name a valid JavaScript identifier?

a) Yes
b) No

41) What is the output of following JavaScript code?

a) first
b) undefined
c) First
d) Error

42) Which of these comment lines are used in JavaScript?

(1) // , /* ...... **/
(2) / , /** ......./ , /*
(3) /*......*/ , //
(4) *......* , //

a) Only (4)
b) Only (3)
c) Either (3) or (4)
d) Only (2)

43) What is the output of following JavaScript code?

a) ,%,!,{,[,!,!
b) G,i,v,e,1,0,0
c) Give 100
d) Error

44) Which best describes void?

a) A method
b) A function
c) A statement
d) An operator

45) What is the output of following JavaScript code?

a) 2
b) 12
c) 11
d) 13

46) What is the output of following JavaScript code?

a) first
b) First
c) undefined
d) None of the above

47) What is the output of following JavaScript code?

If you call the function callme(), what will happen?

a) 10
b) Error in calling Function
c) 5
d) None of the above

48) Who invented the JavaScript programming language?

a) Tennis Ritchie
b) James Gosling
c) Brendan Eich

49) Can you write HTML tags inside the JavaScript code as shown below?

");
document.write("

This is another paragraph.

");

a) No
b) Yes
c) Impossible

50) Which feature is supported in MSIE 3.x?

a) split()
b) document.clear()
c) join()
d) charAt()

51) How to speicfy the color of the hypertext links with JavaScript?

a) document.linkColor = "#00FF00";
b) document.LColor = "#00FF00";
c) document.LinkC = "#00FF00";
d) document.hyperTextLink = "#00FF00":

52) What will be the output of following JavaScript code?

a) Position: -7
b) Position: -1
c) null
d) error

53) ________ method returns the number of milliseconds in a date string.

a) setHours()
b) setMinutes()
c) parse()

54) ________ converts a string to floating point numbers.

a) eval
b) ParseInt
c) ParseFloat
d) None

55) ________ attempts to evaluate a string representing any javascript literals or variables, converting it to a number.

a) eval
b) parseFloat
c) parseInt
d) None

56) Which is not an attribute of the cookie property?

a) path
b) host
c) secure
d) domain

57) How do substring() and substr() differ?

a) One is not a method of the String object.
b) substr() takes three arguments, substring() only two.
c) Only one accepts a desired string length as an argument.
d) Besides the spelling, nothing.

58) Which is not a reserved word in JavaScript?

a) interface
b) short
c) program
d) throws

59) In Javascript, which of the following method is used to find out the character at a position in a string?

a) charAt()
b) CharacterAt()
c) CharPos()
d) characAt()

60) What will be the output of following JavaScript code snippter?

a) PHPKB Kn
b) Kn
c) ow
d) n

61) How do you delete an element from an options array?

a) Set it to false.
b) Set it to null.
c) Set it to undefined.
d) Set it to -1

62) Is JavaScript case sensitive language?

a) Yes
b) No

63) JavaScript RegExp Object has modifier ’i’ to __________

a) Perform case-sensitive matching
b) Perform case-insensitive matching
c) Perform both case-sensitive&case-insensitive matching

64) What are the following looping structures are available in JavaScript?

a) for, foreach
b) foreach, whileloop
c) do-while loop, foreach
d) for, while loop

65) Which of these is not a method of the Math object?

a) atan()
b) atan2()
c) eval()
d) acos()

66) What will be the output of following JavaScript code snippter?

a) 9123
b) 91234
c) 80000
d) None of the above

67) In JavaScript, RegExp Object Method test() is used to search a string and returns _________

a) true or false
b) found value
c) index
d) None of the above

68) What property would you use to redirect a visitor to another page?

a) document.URL
b) window.location.href
c) document.location.href
d) link.href

69) In JavaScript, which of the statements below can be used for string declaration?

1) var cst = "PHPKB Knowledge Base Software";
2) var cst = new String("PHPKB Knowledge Base Software");

a) Either (1) or (2)
b) Only (1)
c) Neither (1) nor (2)
d) Only (2)

70) What will be the output of following copde snippet?

a) 15
b) 16
c) 19
d) 17

71) What will be the output of following copde snippet?

a) Eat
b) eat
c) undefined
d) Eat eat

72) What will be the output of following copde snippet?

document.write(pattern.exec(cst) + " ");
document.write(pattern.exec(cst) + " ");
document.write(pattern.exec(cst) + " ");
}

a) in in In
b) in in in
c) in in null
d) in null null

73) Which method is used to remove focus from the specified object?

a) blur()
b) focus()
c) None

74) What does parseFloat("FF2") evaluates to?

a) 152
b) FF2
c) NaN
d) None

75) eval((20*4)=?

a) Nan
b) 204
c) 24
d) 80

76) What will be the output of following JavaScript code?

a) null
b) Base
c) BASE
d) Error

77) JavaScript is a ________ typed language.

a) tightly
b) loosely

Answers of JavaScript Interview Quiz Questions

(1) a (2) c (3) a (4) a (5) a (6) a (7) c (8) c (9) c (10) d
(11) a (12) c (13) b (14) a (15) a (16) b (17) b (18) b (19) c (20) c
(21) d (22) a (23) a (24) b (25) b (26) d (27) a (28) a (29) a (30) d
(31) a (32) a (33) a (34) a (35) c (36) b (37) a (38) b (39) c (40) b
(41) a (42) b (43) a (44) d (45) b (46) c (47) a (48) c (49) b (50) d
(51) a (52) b (53) c (54) c (55) a (56) b (57) c (58) c (59) a (60) d
(61) b (62) a (63) b (64) d (65) c (66) a (67) a (68) b (69) a (70) b
(71) b (72) c (73) a (74) c (75) d (76) b (77) b

  1. Thank you so much for sharing these javascript interview questions and answers. I am preparing for the interview of a web developer and I was looking for such a collection of Javascript questions with answers.

Powered by PHPKB Knowledge Base Software