Latest JavaScript Interview Questions and Answers PDF - CodeProject

January 18, 2018 | Author: AnkitSinghChauhan | Category: Java Script, Array Data Type, Array Data Structure, Portable Document Format, Software Development
Share Embed Donate


Short Description

Download Latest JavaScript Interview Questions and Answers PDF - CodeProject...

Description

2/6/2016

Latest JavaScript Interview Questions and Answers PDF ­ CodeProject

12,062,666 members ﴾47,291 online﴿ Sign up for our free weekly Web Developer Newsletter.

articles

Q&A

forums

Sign in

×

Search for articles, questions, tips

lounge

Latest JavaScript Interview Questions and Answers PDF Vikas ahlawat ‐ www.tutoriz.com, 3 Apr 2014

CPOL

Rate this:

   4.66 ﴾65 votes﴿ JavaScript Interview Questions Answers

Introduction Below is the list of latest and updated JavaScript interview questions and their answers for freshers as well as experienced users. These interview questions will help you to prepare for the interviews, So let's start....

JavaScript Interview Questions for both Experienced Programmers and Freshers 1﴿ What is JavaScript? Ans:JavaScript is a scripting language most often used for client‐side web development. 2﴿ What is the difference between JavaScript and Jscript? Ans:Both JavaScript and Jscript are almost similar. JavaScript was developed by Netscape. Microsoft reverse engineered Javascript and called it JScript. 3﴿ How do we add JavaScript onto a web page? Ans:There are several way for adding JavaScript on a web page, but there are two ways which are commonly used by developers If your script code is very short and only for single page, then following ways are the best: a﴿ You can place ʳ•…”‹’––›’‡ʰɑ–‡š–ŵŒƒ˜ƒ•…”‹’–ɑʴ tag inside the ʳŠ‡ƒ†ʴ element.

Code Hide   Copy Code

ʳŠ‡ƒ†ʴ ʳ–‹–Ž‡ʴƒ‰‡‹–Ž‡ʳŵ–‹–Ž‡ʴ ʳ•…”‹’–Žƒ‰—ƒ‰‡ʰɑ ƒ˜ƒ…”‹’–ɑ–›’‡ʰɑ–‡š–ŵŒƒ˜ƒ•…”‹’–ɑʴ ˜ƒ”ƒ‡ʰɑ‹ƒ•ŠŽƒ™–ƒɑ ƒŽ‡”–ſƒ‡ƀŚ ʳŵ•…”‹’–ʴ ʳŵŠ‡ƒ†ʴ b﴿ If your script code is very large, then you can make a JavaScript file and add its path in the following way:

http://www.codeproject.com/Articles/620811/Latest­JavaScript­Interview­Questions­and­Answers

1/9

2/6/2016

Latest JavaScript Interview Questions and Answers PDF ­ CodeProject

Code Hide   Copy Code

ʳŠ‡ƒ†ʴ ʳ–‹–Ž‡ʴƒ‰‡‹–Ž‡ʳŵ–‹–Ž‡ʴ ʳ•…”‹’––›’‡ʰɑ–‡š–ŵŒƒ˜ƒ•…”‹’–ɑ•”…ʰɑ›Œƒ˜ƒ•…”‹’–ŜŒ•ɑʴʳŵ•…”‹’–ʴ ʳŵŠ‡ƒ†ʴ 4﴿ Is JavaScript case sensitive? Ans:Yes! A function ‰‡–Ž‡‡–› †is not the same as ‰‡–Ž‡‡–„› . 5﴿ What are the types used in JavaScript? Ans:–”‹‰, —„‡”, ‘‘Ž‡ƒ, —…–‹‘, „Œ‡…–, —ŽŽ, †‡ˆ‹‡†. 6﴿ What are the boolean operators supported by JavaScript? And Operator: && Or Operator: || Not Operator: ! 7﴿ What is the difference between “==” and “===”? Ans: “==” checks equality only, “===” checks for equality as well as the type. 8﴿ How to access the value of a textbox using JavaScript? Ans: ex:‐

Code Hide   Copy Code

ʳŠŠ–Žʴ ʳŠ–Žʴ ʳ„‘†›ʴ —ŽŽƒ‡śʳ‹’—––›’‡ʰɑ–‡š–ɑ‹†ʰɑ–š– —ŽŽƒ‡ɑ ƒ‡ʰɑ ‹”•–ƒ‡ɑ˜ƒŽ—‡ʰɑ‹ƒ•ŠŽƒ™ƒ–ɑʴ ʳŵ„‘†›ʴ ʳŵŠ–Žʴ There are following ways to access the value of the above textbox: Hide   Copy Code

˜ƒ”ƒ‡ʰ†‘…—‡–Ŝ‰‡–Ž‡‡–› †ſɐ–š– —ŽŽƒ‡ɐƀŜ˜ƒŽ—‡Ś ƒŽ‡”–ſƒ‡ƀŚ or: we can use the old way: Hide   Copy Code

†‘…—‡–Ŝˆ‘”•ƃɥƄŜ›„—––‘Ŝ ˜ƒ”ƒ‡ʰ†‘…—‡–Ŝˆ‘”•ƃɥƄŜ ‹”•–ƒ‡Ŝ˜ƒŽ—‡Ś ƒŽ‡”–ſƒ‡ƀŚ Note: This uses the "ƒ‡" attribute of the element to locate it. 9﴿ What are the ways of making comments in JavaScript? Ans: Hide   Copy Code

ŵŵ‹•—•‡†ˆ‘”Ž‹‡…‘‡–• ‡šśŞ˜ƒ”šʰɨɥŚŵŵ…‘‡––‡š– http://www.codeproject.com/Articles/620811/Latest­JavaScript­Interview­Questions­and­Answers

2/9

2/6/2016

Latest JavaScript Interview Questions and Answers PDF ­ CodeProject

ŵƋ Ƌŵ‹•—•‡†ˆ‘”„Ž‘……‘‡–• ex:‐ Hide   Copy Code

˜ƒ”šʰɨɥŚŵƋ–Š‹•‹• „Ž‘……‘‡–‡šƒ’Ž‡ŜƋŵ 10﴿ How will you get the Š‡…„‘šstatus whether it is checked or not? Ans: Hide   Copy Code

˜ƒ”•–ƒ–—•ʰ†‘…—‡–Ŝ‰‡–Ž‡‡–› †ſɐ…Š‡…„‘šɨɐƀŜ…Š‡…‡†Ś ƒŽ‡”–ſ•–ƒ–—•ƀŚ will return –”—‡or ˆƒŽ•‡. 11﴿ How to create arrays in JavaScript? Ans:There are two ways to create array in JavaScript like other languages: a﴿ The first way to create array Declare Array:

Code Hide   Copy Code

˜ƒ”ƒ‡•ʰ‡™””ƒ›ſƀŚ ††Ž‡‡–•‹””ƒ›śŞ ƒ‡•ƃɥƄʰɑ‹ƒ•ɑŚ ƒ‡•ƃɨƄʰɑ•Š‹•ŠɑŚ ƒ‡•ƃɩƄʰɑ‹Š‹ŽɑŚ b﴿ This is the second way: Hide   Copy Code

˜ƒ”ƒ‡•ʰ‡™””ƒ›ſɑ‹ƒ•ɑřɑ•Š‹•Šɑřɑ‹Š‹ŽɑƀŚ 12﴿ If an array with name as "names" contain three elements, then how will you print the third element of this array? Ans: Print third array element †‘…—‡–Ŝ™”‹–‡ſƒ‡•ƃɩƄƀŚ Note:‐ Array index starts with ɥ. 13﴿ How do you submit a form using JavaScript? Ans:Use †‘…—‡–Ŝˆ‘”•ƃɥƄŜ•—„‹–ſƀŚ 14﴿ What does isNaN function do? Ans: It returns –”—‡if the argument is not a number. Example:

Code Hide   Copy Code

†‘…—‡–Ŝ™”‹–‡ſ‹•ƒſɑ ‡ŽŽ‘ɑƀʫɑʳ„”ʴɑƀŚ †‘…—‡–Ŝ™”‹–‡ſ‹•ƒſɑɩɥɨɪŵɥɭŵɩɪɑƀʫɑʳ„”ʴɑƀŚ †‘…—‡–Ŝ™”‹–‡ſ‹•ƒſɨɩɪƀʫɑʳ„”ʴɑƀŚ The output will be: Hide   Copy Code

–”—‡ –”—‡ ˆƒŽ•‡ http://www.codeproject.com/Articles/620811/Latest­JavaScript­Interview­Questions­and­Answers

3/9

2/6/2016

Latest JavaScript Interview Questions and Answers PDF ­ CodeProject

15﴿ What is the use of Math Object in JavaScript? Ans: The math object provides you properties and methods for mathematical constants and functions. ex:‐

Code Hide   Copy Code

˜ƒ”šʰƒ–ŠŜ Śŵŵ‡–—”•  ˜ƒ”›ʰƒ–ŠŜ•“”–ſɨɭƀŚŵŵ‡–—”•–Š‡•“—ƒ”‡”‘‘–‘ˆɮɳ ˜ƒ”œʰƒ–ŠŜ•‹ſɰɥƀŚ‡–—”•–Š‡•‹‡‘ˆɰɥ 16﴿ What do you understand by this keyword in JavaScript? Ans: In JavaScript the –Š‹• is a context‐pointer and not an object pointer. It gives you the top‐most context that is placed on the stack. The following gives two different results ﴾in the browser, where by‐default the ™‹†‘™ object is the 0‐level context﴿: Hide   Copy Code

˜ƒ”‘„ŒʰƇ‘—–‡”‹†–ŠśɩɥƈŚ  ˆ—…–‹‘•ƒ›ſƀƇ ƒŽ‡”–ſ–Š‹•Ŝ‘—–‡”‹†–ŠƀŚ ƈ  •ƒ›ſƀŚŵŵ™‹ŽŽƒŽ‡”–™‹†‘™Ŝ‘—–‡”‹†–Š •ƒ›Ŝƒ’’Ž›ſ‘„ŒƀŚŵŵ™‹ŽŽƒŽ‡”–‘„ŒŜ‘—–‡”‹†–Š 17﴿ What does "1"+2+4 evaluate to? Ans: Since ɨis a •–”‹‰, everything is a •–”‹‰, so the result is ɨɩɫ. 18﴿ What does 3+4+"7" evaluate to? Ans: Since ɪand ɫare integers, this is number arithmetic, since ɮis a •–”‹‰, it is concatenation, so ɮɮis the result. 19﴿ How do you change the style/class on any element using JavaScript? Ans:

Code Hide   Copy Code

†‘…—‡–Ŝ‰‡–Ž‡‡–› †ſũ›‡š–ŪƀŜ•–›Ž‡Ŝˆ‘–‹œ‡ʰũɨɥɑŚ ‐or‐ Hide   Copy Code

†‘…—‡–Ŝ‰‡–Ž‡‡–› †ſũ›‡š–ŪƀŜ…Žƒ••ƒ‡ʰũƒ›…Žƒ••ŪŚ 20﴿ Does JavaScript support foreach loop? Ans: JavaScript 1.6﴾ECMAScript 5th Edition﴿ support foreach loop, See example here http://jsfiddle.net/gpDWk/ 21﴿ What looping structures are there in JavaScript? Ans: ˆ‘”, ™Š‹Ž‡, †‘‐™Š‹Ž‡loops 22﴿ What is an object in JavaScript, give an example? Ans: An object is just a container for a collection of named values: // Create the ƒobject

Code Hide   Copy Code http://www.codeproject.com/Articles/620811/Latest­JavaScript­Interview­Questions­and­Answers

4/9

2/6/2016

Latest JavaScript Interview Questions and Answers PDF ­ CodeProject

˜ƒ”ƒʰ‡™„Œ‡…–ſƀŚ ƒŜƒ‡ʰɐ‹ƒ•ŠŽƒ™ƒ–ɐŚ ƒŜŽ‹˜‹‰ʰ–”—‡Ś ƒŜƒ‰‡ʰɩɮŚ 23﴿ How you will add function as a property in a JavaScript object? Give an example. Ans:

Code Hide   Copy Code

˜ƒ”ƒʰ‡™„Œ‡…–ſƀŚ ƒŜƒ‡ʰɐ‹ƒ•ŠŽƒ™ƒ–ɐŚ ƒŜŽ‹˜‹‰ʰ–”—‡Ś ƒŜƒ‰‡ʰɩɮŚ ƒŜ‰‡–ƒ‡ʰˆ—…–‹‘ſƀƇ”‡–—”ƒŜƒ‡Śƈ …‘•‘Ž‡ŜŽ‘‰ſƒŜ‰‡–ƒ‡ſƀƀŚŵŵ‘‰•ɖ‹ƒ•ŠŽƒ™ƒ–ɖŜ 24﴿ What is the similarity between the 1st and 2nd statement? 1st:‐ ˜ƒ”›–”‹‰ʰ‡™–”‹‰ſɐƒŽ‡ɐƀŚŵŵ‘„Œ‡…–Ŝ 2nd:‐ ˜ƒ”›–”‹‰‹–‡”ƒŽʰɐƒŽ‡ɐŚŵŵ”‹‹–‹˜‡•–”‹‰˜ƒŽ—‡ř‘–ƒ‘„Œ‡…–Ŝ Ans: Both will call –”‹‰ſƀconstructor function You can confirm it by running the following statement: Hide   Copy Code

…‘•‘Ž‡ŜŽ‘‰ſ›–”‹‰Ŝ…‘•–”—…–‘”ř›–”‹‰‹–‡”ƒŽŜ…‘•–”—…–‘”ƀŚ 25﴿ What will be the output of the following statements?

Code Hide   Copy Code

˜ƒ”›–”‹‰ʰɐ‹ƒ•ɐŵŵ”‡ƒ–‡ƒ’”‹‹–‹˜‡•–”‹‰‘„Œ‡…–Ŝ ˜ƒ”›–”‹‰‘’›ʰ›–”‹‰Śŵŵ‘’›‹–•˜ƒŽ—‡‹–‘ƒ‡™˜ƒ”‹ƒ„Ž‡Ŝ ˜ƒ”›–”‹‰ʰ—ŽŽŚŵŵƒ‹’—Žƒ–‡–Š‡˜ƒŽ—‡ …‘•‘Ž‡ŜŽ‘‰ſ›–”‹‰ř›–”‹‰‘’›ƀŚ •śŵŵ‘‰•ɖ—ŽŽ‹ƒ•ɖ 26﴿ Consider the following statements and tell what would be the output of the logs statements? Hide   Copy Code

˜ƒ”’”‹…‡ɨʰɨɥŚ ˜ƒ”’”‹…‡ɩʰɨɥŚ ˜ƒ”’”‹…‡ɪʰ‡™—„‡”ſɐɨɥɐƀŚŵŵ…‘’Ž‡š—‡”‹…‘„Œ‡…–„‡…ƒ—•‡‡™™ƒ•—•‡†Ŝ …‘•‘Ž‡ŜŽ‘‰ſ’”‹…‡ɨʰʰʰ’”‹…‡ɩƀŚ …‘•‘Ž‡ŜŽ‘‰ſ’”‹…‡ɨʰʰʰ’”‹…‡ɪƀŚ Ans: Hide   Copy Code

…‘•‘Ž‡ŜŽ‘‰ſ’”‹…‡ɨʰʰʰ’”‹…‡ɩƀŚŵŵ‘‰•–”—‡Ŝ …‘•‘Ž‡ŜŽ‘‰ſ’”‹…‡ɨʰʰʰ’”‹…‡ɪƀŚŵƋ‘‰•ˆƒŽ•‡„‡…ƒ—•‡’”‹…‡ɰ …‘–ƒ‹•ƒ…‘’Ž‡š—„‡”‘„Œ‡…–ƒ†’”‹…‡ɮ ‹•ƒ’”‹‹–‹˜‡˜ƒŽ—‡ŜƋŵ 27﴿ What would be the output of the following statements? Hide   Copy Code

˜ƒ”‘„Œ‡…–ɨʰƇ•ƒ‡śɐ•ƒ‡ɐƈŚ ˜ƒ”‘„Œ‡…–ɩʰƇ•ƒ‡śɐ•ƒ‡ɐƈŚ …‘•‘Ž‡ŜŽ‘‰ſ‘„Œ‡…–ɨʰʰʰ‘„Œ‡…–ɩƀŚ

http://www.codeproject.com/Articles/620811/Latest­JavaScript­Interview­Questions­and­Answers

5/9

2/6/2016

Latest JavaScript Interview Questions and Answers PDF ­ CodeProject

Ans: // Logs false, JavaScript does not care that they are identical and of the same object type. When comparing complex objects, they are equal only when they reference the same object ﴾i.e., have the same address﴿. Two variables containing identical objects are not equal to each other since they do not actually point at the same object. 28﴿ What would be the output of the following statements?

Code Hide   Copy Code

˜ƒ”‘„Œ‡…–ɨʰƇ•ƒ‡śɐ•ƒ‡ɐƈŚ ˜ƒ”‘„Œ‡…–ɩʰ‘„Œ‡…–ɨŚ …‘•‘Ž‡ŜŽ‘‰ſ‘„Œ‡…–ɨʰʰʰ‘„Œ‡…–ɩƀŚ Ans: // Logs true 29﴿ What is this? Hide   Copy Code

˜ƒ”›””ƒ›ʰƃƃƃƄƄƄŚ Ans: Three dimensional array 30﴿ Name any two JavaScript functions which are used to convert nonnumeric values into numbers? Ans: Hide   Copy Code

—„‡”ſƀ ’ƒ”•‡ –ſƀ ’ƒ”•‡ Ž‘ƒ–ſƀ

Code Hide   Copy Code

˜ƒ”ɨʰ—„‡”ſũ ‡ŽŽ‘™‘”Ž†ŠŪƀŚŵŵƒ ˜ƒ”ɩʰ—„‡”ſũŪƀŚŵŵɫ ˜ƒ”ɪʰ—„‡”ſũɥɥɥɥɨɥŪƀŚŵŵɮɫ ˜ƒ”ɫʰ—„‡”ſ–”—‡ƀŚŵŵɮ ˜ƒ”ɬʰ—„‡”ſƒƀŚŵŵƒ 31﴿ Does JavaScript Support automatic type conversion, If yes give example. Ans: Yes! Javascript support automatic type conversion. You should take advantage of it, It is most common way of type conversion used by Javascript developers. Ex. Hide   Copy Code

˜ƒ”•ʰɐɬɐŚ ˜ƒ”ƒʰ•ƋɨŚ ˜ƒ”„ʰʫ•Ś –›’‡‘ˆſ•ƀŚŵŵɗ•–”‹‰ɗ –›’‡‘ˆſƒƀŚŵŵɗ—„‡”ɗ –›’‡‘ˆſ„ƀŚŵŵɗ—„‡”ɗ *Question﴾31﴿ suggested by Florian Rappl

License This article, along with any associated source code and files, is licensed under The Code Project Open License ﴾CPOL﴿

http://www.codeproject.com/Articles/620811/Latest­JavaScript­Interview­Questions­and­Answers

6/9

2/6/2016

Latest JavaScript Interview Questions and Answers PDF ­ CodeProject

Share EMAIL

TWITTER

About the Author

You may also be interested in... ASP.NET MVC interview questions with answers

Proven Practices for Upgrading or Migrating to Microsoft SharePoint 2013

Latest jQuery interview questions and answers

SAPrefs ‐ Netscape‐like Preferences Dialog

40 important HTML 5 Interview questions with answers

Window Tabs ﴾WndTabs﴿ Add‐In for DevStudio

Comments and Discussions   You must Sign In to use this message board. Search Comments

  Go First Prev Next

My vote of 4 Ujjval Shukla

10‐Jul‐15 23:01

More Javascript interview quizzes Member 11797151 27‐Jun‐15 14:07 Just my opinion Dávid Kocsis 26‐May‐15 3:47 http://www.codeproject.com/Articles/620811/Latest­JavaScript­Interview­Questions­and­Answers

7/9

2/6/2016

Latest JavaScript Interview Questions and Answers PDF ­ CodeProject

My vote of 4 Novakovi 3‐Nov‐14 4:18 Thanks Girish Nama

17‐Oct‐14 19:13

My Vote 5 Shemeemsha RA

6‐Oct‐14 20:52

My vote of 5 Sibeesh KV 16‐Sep‐14 0:07 Very simple for the beginners rvasif 3‐Apr‐14 6:41 Please improve the answer to question 7 gwag 3‐Apr‐14 1:40 My vote of 1 Member 10394796 Nice job chait301

2‐Apr‐14 8:15

4‐Mar‐14 4:02

Great and Simple Endalew 17‐Oct‐13 12:41 Thanks oddadmix

30‐Sep‐13 5:38

My vote of 3 DhruvSakalley

8‐Sep‐13 15:33

My vote of 4 Member 10004231

30‐Aug‐13 0:52

My vote of 5 teeoneone 28‐Aug‐13 0:32 My vote of 4 Nitij Kumar 27‐Aug‐13 2:26 My vote of 5 Juhi Paunikar

26‐Aug‐13 23:48

My vote of 5 Sk. Tajbir 26‐Aug‐13 5:04 Another BIG mistake Florian Rappl 25‐Aug‐13 20:35 Re: Another BIG mistake Vikasahlawat24 25‐Aug‐13 21:12 Re: Another BIG mistake Florian Rappl 26‐Aug‐13 0:09 http://www.codeproject.com/Articles/620811/Latest­JavaScript­Interview­Questions­and­Answers

8/9

2/6/2016

Latest JavaScript Interview Questions and Answers PDF ­ CodeProject

Always prefer literals ... Florian Rappl 25‐Aug‐13 20:26 question 20's answer is not correct, or not up to date David Rogers Dev 25‐Aug‐13 17:06 Re: question 20's answer is not correct, or not up to date Vikasahlawat24 25‐Aug‐13 18:14 Refresh General    Admin   

1 2 Next » News   

Suggestion   

Question   

Bug   

Answer   

Joke   

Praise   

Rant   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages. Permalink | Advertise | Privacy | Terms of Use | Mobile Web02 | 2.8.160204.4 | Last Updated 3 Apr 2014

Select Language ​ ▼ Layout: fixed | fluid Article Copyright 2013 by Vikas ahlawat ‐ www.tutoriz.com Everything else Copyright © CodeProject, 1999‐2016

http://www.codeproject.com/Articles/620811/Latest­JavaScript­Interview­Questions­and­Answers

9/9

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF