Anda di halaman 1dari 15

1/25/13

JavaScript Interview Questions and Answers - JavaScript Quiz

PHPKB Knowledge Base Software

Knowledge Management Software


Knowledge Base Home | Glossary | C ontact Us

Home > All C ategories > C areer Advice > Interview Questions
Please fill in your details, w e w ill contact you shortly. First Name Mobile Number DD MM YYYY Last Name Email ID City of Residence Salaried
* All f ields are mandatory

Annual Income Company Name

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.

Additional Information Article Number: 1015

22
Share

C reated: 2011-02-03 2:55 AM Rating:

Article Options Send Article to Friend Export to PDF File del.icio.us Bookmark Reditt Bookmark Digg Bookmark Stumble It Subscribe to Article

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. C lick here to view answers of these JavaScript Interview Questions. 1) What is the output of following JavaScript code? <cit srp tp=tx/aacit> ye"etjvsrp" x4"" =+4; dcmn.rt() ouetwiex; <srp> /cit a) 44 b) 8 c) 4 d) Error output 2) What is the output of following JavaScript code? <cittp=tx/aacit> srp ye"etjvsrp" vrct="hdaSfwr Tcnlge" a s Cah otae ehoois; vrrsl =ctslt""; a eut s.pi( ) dcmn.rt(eut; ouetwiersl) <srp> /cit a) C hadha 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) C hadha,Software,Technologies d) C hadha Software Technologies 3) Is it possible to nest functions in JavaScript? www.knowledgebase-script.com/demo/article-1015.html

Imagine Your Business in


www.londonandpartners.com/Imagine London - Discover What You Need To Set Up Your Business In London Now!

Tweet It Stay Informed by Email

Useful Links

1/15

1/25/13 JavaScript Interview Questions and Answers - JavaScript Quiz 3) Is it possible to nest functions in JavaScript?
a) True b) False 4) What is the output of following JavaScript code? <cittp=tx/aacit> srp ye"etjvsrp" dcmn.rt(aiao.pCdNm) ouetwienvgtrapoeae; <srp> /cit 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? <cittp=tx/aacit> srp ye"etjvsrp" fnto x) ucin ( { vrs "od10" a = Go 0%; vrpten=/Dg a atr \/; vrotu=smthpten; a upt .ac(atr) dcmn.rt(upt; ouetwieotu) } <srp> /cit a) Good % b) 1,0,0 c) G,o,o,d,% d) Error 9) What is the output of following JavaScript code? <cittp=tx/aacit> srp ye"etjvsrp" vrct"HDASFWR TCNLGE" a s=CAH OTAE EHOOIS; aetctcaA(s.egh1) lr(s.hrtctlnt-); <srp> /cit a) P b) E www.knowledgebase-script.com/demo/article-1015.html C ore Java Interview Search Knowledge Base Questions & Answers PHP keywords Search Interview Questions - GO PHP Interview Questions and Answers

2/15

1/25/13 b) E
c) S d) Error

JavaScript Interview Questions and Answers - JavaScript Quiz

10) Choose the client-side JavaScript object: a) Database b) C ursor c) C lient 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? <cittp=tx/aacit> srp ye"etjvsrp" fnto xzt ucin (,) { aetxlnt) lr(.egh; } <srp> /cit 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

www.knowledgebase-script.com/demo/article-1015.html

3/15

1/25/13

JavaScript Interview Questions and Answers - JavaScript Quiz

17) What is the output of following JavaScript code? <cittp=tx/aacit> srp ye"etjvsrp" fnto x) ucin ( { vrs="ult 10![!; a Qaiy 0%{!" vrpten=/wg a atr \/; vrotu =smthpten; a upt .ac(atr) dcmn.rt(upt; ouetwieotu) } <srp> /cit 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? <cittp=tx/aacit> srp ye"etjvsrp" vrct=nwAry) a s e ra(; ct0 ="e Dvlpet; s[] Wb eeomn" ct1 ="plcto Dvlpet s[] Apiain eeomn" ct2 ="etn" s[] Tsig ct3 ="hdaSfwr Tcnlge" s[] Cah otae ehoois; dcmn.rt(s[,,,]; ouetwiect0123) <srp> /cit a) Error b) C hadha Software Technologies c) Web Development d) Web Development,Application Development,Testing,C hadha 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? <cittp=tx/aacit> srp ye"etjvsrp" fnto x) ucin ( { dcmn.rt(++8) ouetwie25""; } <srp> /cit a) 258 b) Error c) 7

www.knowledgebase-script.com/demo/article-1015.html

4/15

1/25/13
d) 78

JavaScript Interview Questions and Answers - JavaScript Quiz

22) _________ 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? <cittp=tx/aacit> srp ye"etjvsrp" fnto x) ucin ( { vrs "ult 10" a = qaiy 0%; vrpten=/dg a atr \/; vrotu=smthpten; a upt .ac(atr) dcmn.rt(upt; ouetwieotu) } <srp> /cit 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? <cittp=tx/aacit> srp ye"etjvsrp" vrct(4%)=)"el""y" a s=(52=0?hlo:be; dcmn.rt(s) ouetwiect; <srp> /cit a) hello b) bye c) Error in string handling d) None of the above 26) What is the output of following JavaScript code? <cittp=tx/aacit> srp ye"etjvsrp" fnto x) ucin ( { vrct="hdaSfwr Tcnlge" a s Cah otae ehoois; vrpten=nwRgx(SFWR"""; a atr e eEp"OTAE,i) dcmn.rt(s.ac(atr); ouetwiectmthpten) } <srp> /cit a) Error b) SOFTWARE c) Software

www.knowledgebase-script.com/demo/article-1015.html

5/15

1/25/13
d) null

JavaScript Interview Questions and Answers - JavaScript Quiz

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) C hoose the external object among the follwing: a) Date b) Option c) Layer d) C heckbox 31) C hoose the four symbol pairs that represent RegExp properties lastMatch, lastParent, leftC ontext, and rightC ontext, 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? www.knowledgebase-script.com/demo/article-1015.html

6/15

1/25/13 JavaScript Interview Questions and Answers - JavaScript Quiz 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? <cittp=tx/aacit> srp ye"etjvsrp" fnto x) ucin ( { vrct="eaefs goigSfwr Cmaylctdi Ceni Ida" a s W r at rwn otae opn oae n hna, ni.; vrpten=nwRgx(i""i) a atr e eEp"n,g"; dcmn.rt(atr.xcct +""; ouetwieptenee(s) ) dcmn.rt(atr.xcct +""; ouetwieptenee(s) ) dcmn.rt(atr.xcct +""; ouetwieptenee(s) ) } <srp> /cit 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) ?_name is it valid javascript identifier? a) Yes b) No 41) What is the output of following JavaScript code? <cittp=tx/aacit> srp ye"etjvsrp" fnto x) ucin ( { vrct="is cm,frtsre" a s Frt oe is evd; vrpten=/is/i a atr frtg; dcmn.rt(s.ac(atr)1) ouetwiectmthpten[]; } <srp> /cit a) first b) undefined

www.knowledgebase-script.com/demo/article-1015.html

7/15

1/25/13
c) First d) Error

JavaScript Interview Questions and Answers - JavaScript Quiz

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? <cittp=tx/aacit> srp ye"etjvsrp" fnto x) ucin ( { vrs="ie10![!; a Gv 0%{!" vrpten=/Wg a atr \/; vrotu =smthpten; a upt .ac(atr) dcmn.rt(upt; ouetwieotu) } <srp> /cit 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? <cittp=tx/aacit> srp ye"etjvsrp" vrct"hdaSfwr Tcnlge" a s=Cah otae ehoois; vrrsl =s.atneO(a) a eut ctlsIdxf""; dcmn.rt(eut; ouetwiersl) <srp> /cit a) 2 b) 12 c) 11 d) 13 46) What is the output of following JavaScript code? <cittp=tx/aacit> srp ye"etjvsrp" fnto x) ucin ( { vrct="is cm,frtsre" a s Frt oe is evd; vrpten=/is/; a atr frtg www.knowledgebase-script.com/demo/article-1015.html

8/15

1/25/13 vrpten=/is/; a atr frtg


} <srp> /cit a) first b) First c) undefined d) None of the above

JavaScript Interview Questions and Answers - JavaScript Quiz

dcmn.rt(s.ac(atr)1) ouetwiectmthpten[];

47) What is the output of following JavaScript code? <cittp=tx/aacit> srp ye"etjvsrp" fnto smx ucin u() { fnto ady ucin d() { rtr xy eun +; } rtr ad eun d; } fnto clm( ucin ale) { rsl=u()5; eutsm5() aetrsl) lr(eut; } <srp> /cit 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) C an you write HTML tags inside the JavaScript code as shown below? <cittp=tx/aacit> srp ye"etjvsrp" dcmn.rt(<1Ti i ahaig/1"; ouetwie"h>hs s edn<h>) dcmn.rt(<>hsi aprgah<p"; ouetwie"pTi s aarp./>) dcmn.rt(<>hsi aohrprgah<p"; ouetwie"pTi s nte aarp./>) <srp> /cit a) No b) Yes c) Impossible 50) Which feature is supported in MSIE 3.x? a) split() b) document.clear() c) join()

www.knowledgebase-script.com/demo/article-1015.html

9/15

1/25/13
d) charAt()

JavaScript Interview Questions and Answers - JavaScript Quiz

51) How to speicfy the color of the hypertext links with JavaScript? a) document.linkC olor="#00FF00"; b) document.LC olor="#00FF00"; c) document.LinkC ="#00FF00"; d) document.hyperTextLink="#00FF00": 52) What will be the output of following JavaScript code? <cittp=tx/aacit> srp ye"etjvsrp" fnto x) ucin ( { vrct="hdaSfwr Tcnlge" a s Cah otae ehoois; vrpten=/otae; a atr sfwr/ vrotu=ctsac(atr) a upt s.erhpten; dcmn.rt(Psto:"+otu) ouetwie"oiin upt; } <srp> /cit 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. www.knowledgebase-script.com/demo/article-1015.html

10/15

1/25/13 JavaScript Interview Questions and Answers - JavaScript Quiz c) Only one accepts a desired string length as an argument.
d) Besides the spelling, nothing. 58) Which is not a reserved word? 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) C haracterAt() c) C harPos() d) characAt() 60) What will be the output of following JavaScript code snippter? <cittp=tx/aacit> srp ye"etjvsrp" vrct="HK KoldeBs Sfwr" a s PPB nweg ae otae; vrrsl =s.usrn(,) a eut ctsbtig78; dcmn.rt(eut; ouetwiersl) <srp> /cit 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() www.knowledgebase-script.com/demo/article-1015.html

11/15

1/25/13 d) acos()

JavaScript Interview Questions and Answers - JavaScript Quiz

66) What will be the output of following JavaScript code snippter? <cittp=tx/aacit> srp ye"etjvsrp" vrs="135 o 800" a 9246 r 00?; vrpten=/d4/ a atr \{}; vrotu =smthpten; a upt .ac(atr) dcmn.rt(upt; ouetwieotu) <srp> /cit 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? <cittp=tx/aacit> srp ye"etjvsrp" vrct="hdaSfwr Tcnlge" a s Cah otae ehoois; vrrsl =ctidxf"eh) a eut s.neO(Tc"; dcmn.rt(eut; ouetwiersl) <srp> /cit a) 15 b) 16 c) 19 d) 17 71) What will be the output of following copde snippet? <cittp=tx/aacit> srp ye"etjvsrp" fnto x) ucin ( { vrs="a t lv,btd ntlv t et; a Et o ie u o o ie o a" vrpten=nwRgx(et"; a atr e eEp"a$) www.knowledgebase-script.com/demo/article-1015.html

12/15

1/25/13
vrpten=nwRgx(et"; a atr e eEp"a$) dcmn.rt(atr.xcs) ouetwieptenee(); } <srp> /cit a) Eat b) eat c) undefined d) Eat eat

JavaScript Interview Questions and Answers - JavaScript Quiz

72) What will be the output of following copde snippet? <cittp=tx/aacit> srp ye"etjvsrp" fnto x) ucin ( { vrct="eaeFs GoigSfwr Cmaylctdi Jlnhr a s W r at rwn otae opn oae n aada, Ida" ni.; vrpten=nwRgx(i"""; a atr e eEp"n,g) dcmn.rt(atr.xcct +""; ouetwieptenee(s) ) dcmn.rt(atr.xcct +""; ouetwieptenee(s) ) dcmn.rt(atr.xcct +""; ouetwieptenee(s) ) } <srp> /cit a) in in In b) in in in c) in in null d) in null null 73) -________ 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? <cittp=tx/aacit> srp ye"etjvsrp" fnto x) ucin ( { vrct="HK KoldeBs Sfwr" a s PPB nweg ae otae; vrpten=nwRgx(BS"""; a atr e eEp"AE,i) dcmn.rt(s.ac(atr); ouetwiectmthpten) } www.knowledgebase-script.com/demo/article-1015.html

13/15

1/25/13 }
<srp> /cit a) null b) Base c) BASE d) Error

JavaScript Interview Questions and Answers - JavaScript Quiz

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 A total of 165 users are reading this article.

Searching for what are the following looping structures are available in javascripts www.amazon.com 1. The Following on Fox
Kevin Bacon stars in The Following. Download a Season Pass on Amazon.

2. Looking for new cell ?

novedadesitzel.vitelwireless.com/

Looking for new cell or pay your bills?


www.ExplainPlease.com

3. Wikipedia Answer Just Ask

Get quick answers back. Do not know the answer? Ask us.
www.ApnaPaisa.com/emicalculator

4. Home Loan EMI Calculator

How much EMI will you have to pay? Just enter amount, tenure & rate.
C hitika |O pt out?

Posted by: Administrator This question has been viewed 70462 times so far. www.knowledgebase-script.com/demo/article-1015.html

14/15

1/25/13 JavaScript Interview Questions and Answers - JavaScript Quiz Posted by: Administrator This question has been viewed 70462 times so far.

Want More? Would you like to be notified when new articles are added to our knowledgebase? Subscribe to our Feed and get instant notifications when new articles are added to the knowledgebase.

C lick Here to view all the questions in the Interview Questions category. File Attachments There are no files attached to this question/article. How helpful was this article to you? User Comments Select Vote Rate

email@nospam.org on Sat, Feb 5th, 2011 at 7:43 AM 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. Related General Knowledge Questions 1. C ore Java Interview Questions & Answers 2. PHP Interview Questions - PHP Interview Questions and Answers

2005-2010 PHPKB Knowle dge Manage m e nt Software


P owered by P H P KB Knowledge Bas e Software

English

www.knowledgebase-script.com/demo/article-1015.html

15/15