{"id":48049,"date":"2018-01-30T11:34:09","date_gmt":"2018-01-30T06:04:09","guid":{"rendered":"http:\/\/blog.odango.com\/?p=48049"},"modified":"2023-02-04T09:31:32","modified_gmt":"2023-02-04T04:01:32","slug":"javascript-interview-questions-and-answers","status":"publish","type":"post","link":"https:\/\/asha24.net\/blog\/javascript-interview-questions-and-answers\/","title":{"rendered":"JavaScript Interview Questions and Answers"},"content":{"rendered":"\n[et_pb_section bb_built=&#8221;1&#8243; next_background_color=&#8221;#000000&#8243;][et_pb_row][et_pb_column type=&#8221;4_4&#8243;][et_pb_post_title _builder_version=&#8221;3.0.106&#8243; title=&#8221;on&#8221; meta=&#8221;off&#8221; author=&#8221;on&#8221; date=&#8221;on&#8221; categories=&#8221;on&#8221; comments=&#8221;on&#8221; featured_image=&#8221;off&#8221; featured_placement=&#8221;below&#8221; text_color=&#8221;dark&#8221; text_background=&#8221;off&#8221; title_font=&#8221;Titillium Web||||||||&#8221; title_font_size=&#8221;47&#8243; title_font_size_tablet=&#8221;40&#8243; title_font_size_phone=&#8221;35&#8243; title_font_size_last_edited=&#8221;on|desktop&#8221; title_text_color=&#8221;rgba(0,0,0,0.8)&#8221; title_text_align=&#8221;left&#8221; text_shadow_horizontal_length=&#8221;0.08em&#8221; text_shadow_vertical_length=&#8221;0.08em&#8221; text_shadow_blur_strength=&#8221;0.08em&#8221; title_text_shadow_horizontal_length=&#8221;0.08em&#8221; title_text_shadow_vertical_length=&#8221;0.08em&#8221; custom_margin=&#8221;|||10%&#8221; \/][\/et_pb_column][\/et_pb_row][et_pb_row][et_pb_column type=&#8221;4_4&#8243;][et_pb_text _builder_version=&#8221;3.0.106&#8243; background_layout=&#8221;light&#8221; text_font=&#8221;Titillium Web|300|||||||&#8221; text_font_size=&#8221;20&#8243; text_font_size_last_edited=&#8221;on|desktop&#8221; text_text_color=&#8221;rgba(0,0,0,0.8)&#8221; text_line_height=&#8221;1.6em&#8221; max_width=&#8221;800px&#8221; custom_margin=&#8221;|||10%&#8221; text_line_height_last_edited=&#8221;off|phone&#8221; max_width_last_edited=&#8221;off|phone&#8221; custom_margin_last_edited=&#8221;off|desktop&#8221;]\r\n\r\n<strong>1) What is JavaScript?<\/strong>\r\n\r\n<strong>Ans1:<\/strong>\u00a0JavaScript is a general-purpose programming language designed to let programmers of all skill levels control the behavior of software objects. The language is used most widely today in Web browsers whose software objects tend to represent a variety of HTML elements in a document and the document itself. But the language can be&#8211;and is&#8211;used with other kinds of objects in other environments. For example, Adobe Acrobat Forms uses JavaScript as its underlying scripting language to glue together objects that are unique to the forms generated by Adobe Acrobat. Therefore, it is important to distinguish JavaScript, the language, from the objects it can communicate with in any particular environment. When used for Web documents, the scripts go directly inside the HTML documents and are downloaded to the browser with the rest of the HTML tags and content.\r\n\r\n<hr \/>\r\n\r\n<strong>2) How is JavaScript different from Java?<\/strong>\r\n\r\n<strong>Ans<\/strong>: JavaScript was developed by Brendan Eich of Netscape; Java was developed at Sun Microsystems. While the two languages share some common syntax, they were developed independently of each other and for different audiences. Java is a full-fledged programming language tailored for network computing; it includes hundreds of its own objects, including objects for creating user interfaces that appear in Java applets (in Web browsers) or standalone Java applications. In contrast, JavaScript relies on whatever environment it&#8217;s operating in for the user interface, such as a Web document&#8217;s form elements.\r\nJavaScript was initially called LiveScript at Netscape while it was under development. A licensing deal between Netscape and Sun at the last minute let Netscape plug the &#8220;Java&#8221; name into the name of its scripting language. Programmers use entirely different tools for Java and JavaScript. It is also not uncommon for a programmer of one language to be ignorant of the other. The two languages don&#8217;t rely on each other and are intended for different purposes. In some ways, the &#8220;Java&#8221; name on JavaScript has confused the world&#8217;s understanding of the differences between the two. On the other hand, JavaScript is much easier to learn than Java and can offer a gentle introduction for newcomers who want to graduate to Java and the kinds of applications you can develop with it.\r\n\r\n<hr \/>\r\n\r\n<strong>3) What\u2019s the relationship between JavaScript and ECMAScript?<\/strong>\r\n\r\n<strong>Ans:<\/strong>\u00a0ECMAScript is yet another name for JavaScript (other names include LiveScript). The current JavaScript that you see supported in browsers is ECMAScript revision 3.\r\n\r\n<hr \/>\r\n\r\n<strong>4) How do you submit a form using Javascript?<\/strong>\r\n\r\n<strong>Ans:<\/strong>\u00a0Use document.forms[0].submit();\r\n(0 refers to the index of the form \u2013 if you have more than one form in a page, then the first one has the index 0, second has index 1 and so on).\r\n\r\n<hr \/>\r\n\r\n<strong>5) Text From Your Clipboard?<\/strong>\r\n\r\n<strong>Ans:<\/strong>\u00a0It is true, text you last copied for pasting (copy &amp; paste) can be stolen when you visit web sites using a combination of JavaScript and ASP (or PHP, or CGI) to write your possible sensitive data to a database on another server.\r\n\r\n<hr \/>\r\n\r\n<strong>6)\u00a0How to read and write a file using javascript?<\/strong>\r\n\r\n<strong>Ans:<\/strong>\u00a0I\/O operations like reading or writing a file is not possible with client-side javascript. However, this can be done by coding a Java applet that reads files for the script.\r\n\r\n<hr \/>\r\n\r\n<strong>7) How to detect the operating system on the client machine?<\/strong>\r\n\r\n<strong>Ans:<\/strong>\u00a0In order to detect the operating system on the client machine, the navigator.appVersion\r\nstring (property) should be used.\r\n\r\n<hr \/>\r\n\r\n<strong>8) How can JavaScript make a Web site easier to use? That is, are there certain JavaScript techniques that make it easier for people to use a Web site?<\/strong>\r\n\r\n<strong>Ans:<\/strong>\u00a0JavaScript&#8217;s greatest potential gift to a Web site is that scripts can make the page more immediately interactive, that is, interactive without having to submit every little thing to the server for a server program to re-render the page and send it back to the client. For example, consider a top-level navigation panel that has, say, six primary image map links into subsections of the Web site. With only a little bit of scripting, each map area can be instructed to pop up a more detailed list of links to the contents within a subsection whenever the user rolls the cursor atop a map area. With the help of that popup list of links, the user with a scriptable browser can bypass one intermediate menu page. The user without a scriptable browser (or who has disabled JavaScript) will have to drill down through a more traditional and time-consuming path to the desired content.\r\n\r\n<hr \/>\r\n\r\n<strong>9) How can JavaScript be used to improve the &#8220;look and feel&#8221; of a Web site? By the same token, how can JavaScript be used to improve the user interface?<\/strong>\r\n\r\n<strong>Ans:<\/strong>\u00a0On their own, Web pages tend to be lifeless and flat unless you add animated images or more bandwidth-intensive content such as Java applets or other content requiring plug-ins to operate (ShockWave and Flash, for example).\r\nEmbedding JavaScript into an HTML page can bring the page to life in any number of ways.\r\n\r\nPerhaps the most visible features built into pages recently with the help of JavaScript are the so-called image rollovers: roll the cursor atop a graphic image and its appearance changes to a highlighted version as a feedback mechanism to let you know precisely what you&#8217;re about to click on. But there are less visible yet more powerful enhancements to pages that JavaScript offers.\r\n\r\nInteractive forms validation is an extremely useful application of JavaScript. While a user is entering data into form fields, scripts can examine the validity of the data&#8211;did the user type any letters into a phone number field?, for instance. Without scripting, the user has to submit the form and let a server program (CGI) check the field entry and then report back to the user. This is usually done in a batch mode (the entire form at once), and the extra transactions take a lot of time and server processing power. Interactive validation scripts can check each form field immediately after the user has entered the data, while the information is fresh in the mind.\r\n\r\nAnother helpful example is embedding small data collections into a document that scripts can look up without having to do all the server programming for database access. For instance, a small company could put its entire employee directory on a page that has its own search facility built into the script. You can cram a lot of text data into scripts no larger than an average image file, so it&#8217;s not like the user has to wait forever for the data to be downloaded.\r\n\r\nOther examples abound, such as interactive tree-structure tables of contents. More modern scriptable browsers can be scripted to pre-cache images during the page&#8217;s initial download to make them appear lickety-split when needed for image swapping. I&#8217;ve even written some multi-screen interactive applications that run entirely on the client, and never talk to the server once everything is downloaded.\r\n\r\n<hr \/>\r\n\r\n<strong>10) What are JavaScript types?<\/strong>\r\n\r\n<strong>Ans:<\/strong>\u00a0Number, String, Boolean, Function, Object, Null, Undefined.\r\n\r\n<hr \/>\r\n\r\n<strong>11) How do you convert numbers between different bases in JavaScript?<\/strong>\r\n\r\n<strong>Ans:<\/strong>\u00a0Use the parseInt() function, that takes a string as the first parameter and the base as a second parameter. So to convert hexadecimal 3F to decimal, use parseInt (&#8220;3F&#8221;, 16);\r\n\r\n<hr \/>\r\n\r\n<strong>12) How to create arrays in JavaScript?<\/strong>\r\n\r\n<strong>Ans:<\/strong>\u00a0We can declare an array like this\r\nvar scripts = new Array();\r\nWe can add elements to this array like this\r\nscripts[0] = &#8220;PHP&#8221;;\r\nscripts[1] = &#8220;ASP&#8221;;\r\nscripts[2] = &#8220;JavaScript&#8221;;\r\nscripts[3] = &#8220;HTML&#8221;;\r\n\r\nNow our array script\u00a0has 4 elements inside it and we can print or access them by using their index number. Note that index number starts from 0. To get the third element of the array we have to use the index number 2. Here is the way to get the third element of an array.\r\ndocument.write(scripts[2]);\r\nWe also can create an array like this\r\nvar no_array = new Array(21, 22, 23, 24, 25);\r\n\r\n<hr \/>\r\n\r\n<strong>13)\u00a0What does the &#8220;Access is Denied&#8221; IE error mean?<\/strong>\r\n\r\n<strong>Ans:\u00a0<\/strong>The &#8220;Access Denied&#8221; error in any browser is due to the following reason.\r\n\r\nA javascript in one window or frame is tries to access another window or frame whose document&#8217;s domain is different from the document containing the script.\r\n\r\n<hr \/>\r\n\r\n<strong>14) What\u00a0<\/strong><strong>is<\/strong><strong>\u00a0a fixed-width table and its advantages?<\/strong>\r\n\r\n<strong>Ans:<\/strong>\u00a0Fixed width tables are rendered by the browser based on the widths of the columns in the first row, resulting in a faster display in case of large tables. Use the CSS style table-layout:fixed to specify a fixed width table.\r\nIf the table is not specified to be of fixed width, the browser has to wait till all data is downloaded and then infer the best width for each of the columns. This process can be very slow for large tables.\r\n\r\nExample of using Regular Expressions for syntax checking in JavaScript&#8230;\r\nvar re = new RegExp(&#8220;^(&amp;[A-Za-z_0-9]{1,}=[A-Za-z_0-9]{1,})*$&#8221;);\r\nvar text = myWidget.value;\r\nvar OK = re.test(text);\r\nif( ! OK ) {\r\nalert(&#8220;The extra parameters need some work.\\r\\n Should be something like: \\&#8221;&amp;a=1&amp;c=4\\&#8221;&#8221;);\r\n}\r\n\r\n<hr \/>\r\n\r\n<strong>15) Where are cookies actually stored on the hard disk?<\/strong>\r\n<strong>Ans:<\/strong>\u00a0This depends on the user&#8217;s browser and OS.\r\nIn the case of Netscape with Windows OS, all the cookies are stored in a single file called cookies.txt\r\nc:\\Program Files\\Netscape\\Users\\username\\cookies.txt\r\nIn the case of IE, each cookie is stored in a separate file namely\u00a0username@website.txt.\r\nc:\\Windows\\Cookies\\username@Website.txt\r\n\r\n<hr \/>\r\n\r\n<strong>16) Are Java and JavaScript the Same?<\/strong>\r\n\r\n<strong>Ans:<\/strong>\u00a0No.java and javascript are two different languages.\r\n\r\nJava is a powerful object &#8211; oriented programming language like C++,C whereas Javascript is a client-side scripting language with some limitations.\r\n\r\n<hr \/>\r\n\r\n<strong>17) What can javascript programs do?<\/strong>\r\n\r\n<strong>Ans:<\/strong>\u00a0Generation of HTML pages on-the-fly without accessing the Web server. The user can be given control over the browser like User input validation Simple computations can be performed on the client&#8217;s machine The user&#8217;s browser, OS, screen size, etc. can be detected Date and Time Handling.\r\n\r\n<hr \/>\r\n\r\n<strong>18) How to set an HTML document&#8217;s background color?<\/strong>\r\n\r\n<strong>Ans:<\/strong>\u00a0document.bgcolor property can be set to any appropriate color.\r\n\r\n<hr \/>\r\n\r\n<strong>19) How can JavaScript be used to personalize or tailor a Web site to fit individual users?<\/strong>\r\n\r\n<strong>Ans:<\/strong>\u00a0JavaScript allows a Web page to perform &#8220;if-then&#8221; kinds of decisions based on browser version, operating system, user input, and, in more recent browsers, details about the screen size in which the browser is running. While a server CGI program can make some of those same kinds of decisions, not everyone has access to or the expertise to create CGI programs. For example, an experienced CGI programmer can examine information about the browser whenever a request for a page is made; thus a server so equipped might serve up one page for Navigator users and a different page for Internet Explorer users.\r\n\r\nBeyond browser and operating system version, a CGI program can&#8217;t know more about the environment. But a JavaScript-enhanced page can instruct the browser to render only certain content based on the browser, operating system, and even the screen size.\r\n\r\nScripting can even go further if the page author desires. For example, the author may include a preference screen that lets the user determine the desired background and text color combination. A script can save this information on the client in a well-regulated local file called a cookie. The next time the user comes to the site, scripts in its pages look to the cookie info and render the page in the color combination selected previously. The server is none the wiser, nor does it have to store any visitor-specific information.\r\n\r\n<hr \/>\r\n\r\n<strong>20) Are you concerned that older browsers don&#8217;t support JavaScript and thus exclude a set of Web users? individual users?<\/strong>\r\n\r\n<strong>Ans:<\/strong>\u00a0Fragmentation of the installed base of browsers will only get worse. By definition, it can never improve unless absolutely everyone on the planet threw away their old browsers and upgraded to the latest gee-whiz versions. But even then, there are plenty of discrepancies between the scriptability of the latest Netscape Navigator and Microsoft Internet Explorer.\r\nThe situation makes scripting a challenge, especially for newcomers who may not be aware of the limitations of earlier browsers. A lot of effort in my books and ancillary material goes toward helping scripters know what features work in which browsers and how to either workaround limitations in earlier browsers or raise the compatibility common denominator.\r\nDesigning scripts for a Web site requires making some hard decisions about if, when, and how to implement the advantages scripting offers a page to your audience. For public Web sites, I recommend using scripting in an additive way: let sufficient content stand on its own, but let scriptable browser users receive an enhanced experience, preferably with the same HTML document.\r\n\r\n<hr \/>\r\n\r\n<strong>21) What does isNaN function do?<\/strong>\r\n\r\n<strong>Ans:\u00a0<\/strong>Return true if the argument is not a number.\r\n\r\n<hr \/>\r\n\r\n<strong>22) What is negative infinity?<\/strong>\r\n\r\n<strong>Ans:<\/strong>\u00a0It\u2019s a number in JavaScript, derived by dividing negative number by zero.\r\n\r\n<hr \/>\r\n\r\n<strong>23) In a pop-up browser window, how do you refer to the main browser window that opened it?<\/strong>\r\n\r\n<strong>Ans:\u00a0<\/strong>Use window.opener to refer to the main window from pop-ups.\r\n\r\n<hr \/>\r\n\r\n<strong>24) What is the data type of variables of in JavaScript?<\/strong>\r\n\r\n<strong>Ans:\u00a0<\/strong>All variables are of object type in JavaScript.\r\n\r\n<hr \/>\r\n\r\n<strong>25) Methods GET and POST in HTML forms &#8211; what&#8217;s the difference?<\/strong>\r\n\r\n<strong>Ans:<\/strong>\u00a0GET: Parameters are passed in the querystring. Maximum amount of data that can be sent via the GET method is limited to about 2kb.\r\nPOST: Parameters are passed in the request body. There is no limit to the amount of data that can be transferred using POST. However, there are limits on the maximum amount of data that can be transferred in one name\/value pair.\r\n\r\n<hr \/>\r\n\r\n<strong>26) How to write a script for &#8220;Select&#8221; lists using javascript\r\nAns:<\/strong>\r\n\r\n1. To remove an item from a list set it to null\r\nmySelectObject.options[3] = null;\r\n2. To truncate a list set its length to the maximum size you desire\r\nmySelectObject.length = 2;\r\n3. To delete all options in a select object set the length to 0.\r\nmySelectObject.leng\r\n\r\n<hr \/>\r\n\r\n<strong>27) Text From Your Clipboard?<\/strong>\r\n\r\n<strong>Ans:<\/strong>\u00a0It is true, text you last copied for pasting (copy &amp; paste) can be stolen when you visit web sites using a combination of JavaScript and ASP (or PHP, or CGI) to write your possible sensitive data to a database on another server.\r\n\r\n<hr \/>\r\n\r\n<strong>28) What does the &#8220;Access is Denied&#8221; IE error mean?<\/strong>\r\n\r\n<strong>Ans:<\/strong>\u00a0The &#8220;Access Denied&#8221; error in any browser is due to the following reason.\r\nA javascript in one window or frame is tries to access another window or frame whose document&#8217;s domain is different from the document containing the script.\r\n\r\n<hr \/>\r\n\r\n<strong>29) Is a javascript script faster than an ASP script?<\/strong>\r\n\r\n<strong>Ans:\u00a0<\/strong>Yes.Since javascript is a client-side script it does require the web server&#8217;s help for its\r\ncomputation,so it is always faster than any server-side script like ASP,PHP,etc..\r\n\r\n<hr \/>\r\n\r\n<strong>30) Are Java and JavaScript the Same?<\/strong>\r\n\r\n<strong>Ans:<\/strong>\u00a0No.java and javascript are two different languages.\r\nJava is a powerful object &#8211; oriented programming language like C++,C whereas Javascript is a client-side scripting language with some limitations.\r\n\r\n<hr \/>\r\n\r\n<strong>31) How to embed javascript in a web page?<\/strong>\r\n\r\n<strong>Ans:<\/strong>\u00a0javascript code can be embedded in a web page between tags\r\n\r\n<hr \/>\r\n\r\n<strong>32) What and where are the best JavaScript resources on the Web?<\/strong>\r\n\r\n<strong>Ans:<\/strong>\u00a0The Web has several FAQ areas on JavaScript. The best place to start is something called the meta-FAQ [14-Jan-2001 Editor&#8217;s Note: I can&#8217;t point to it anymore, it is broken!], which provides a high-level overview of the JavaScript help available on the Net. As for fact-filled FAQs, I recommend one maintained by Martin Webb and a mini-FAQ that I maintain.\r\nFor interactive help with specific problems, nothing beats the primary JavaScript Usenet newsgroup, comp.lang.javascript. Depending on my work backlog, I answer questions posted there from time to time. Netscape and Microsoft also have vendor-specific developer discussion groups as well as detailed documentation for the scripting and object model implementations.\r\n\r\n<hr \/>\r\n\r\n<strong>33) What are the problems associated with using JavaScript, and are there JavaScript techniques that you discourage?<\/strong>\r\n\r\n<strong>Ans:\u00a0<\/strong>Browser version incompatibility is the biggest problem. It requires knowing how each scriptable browser version implements its object model. You see, the incompatibility rarely has to do with the core JavaScript language (although there have been improvements to the language over time); the bulk of incompatibility issues have to do with the object models that each browser version implements.\r\n\r\nFor example, scripters who started out with Navigator 3 implemented the image rollover because it looked cool. But they were dismayed to find out that the image object wasn&#8217;t scriptable in Internet Explorer 3 or Navigator 2. While there are easy workarounds to make this feature work on newer browsers without disturbing older ones, it was a painful learning experience for many.\r\n\r\nThe second biggest can of worms is scripting connections between multiple windows. A lot of scripters like to have little windows pop up with navigation bars or some such gizmos. But the object models, especially in the older browser versions, don&#8217;t make it easy to work with these windows the minute you put a user in front of them&#8211;users who can manually close windows or change their stacking order. More recently, a glitch in some uninstall routines for Windows 95 applications can disturb vital parts of the system Registry that Internet Explorer 4 requires for managing multiple windows. A scripter can&#8217;t work around this problem, because it&#8217;s not possible to detect the problem in a user&#8217;s machine. I tend to avoid multiple windows that interact with each other. I think a lot of inexperienced Web surfers can also get confused by them.\r\n\r\n<hr \/>\r\n\r\n<strong>34) What Boolean operators does JavaScript support?<\/strong>\r\n\r\n<strong>Ans:\u00a0<\/strong>\u00a0&amp;&amp;, || and !\r\n\r\n<hr \/>\r\n\r\n<strong>35) What does &#8220;1&#8221;+2+4 evaluate to?<\/strong>\r\n\r\n<strong>Ans:<\/strong>\u00a0Since 1 is a string, everything is a string, so the result is 124.\r\n\r\n<hr \/>\r\n\r\n<strong>36) What is the difference between a web-garden and a web-farm?<\/strong>\r\n\r\n<strong>Ans:<\/strong><em><strong>\u00a0<\/strong>Web-garden\u00a0<\/em>&#8211; An IIS6.0 feature where you can configure an application pool as a web-garden and also specify the number of worker processes for that pool. It can help improve performance in some cases.\r\n<em>Web-farm<\/em>\u00a0&#8211; a general term referring to a cluster of physically separate machines, each running a web-server for scalability and performance (contrast this with web-garden which refers to multiple processes on one single physical machine).\r\n\r\n<hr \/>\r\n\r\n<strong>37) How to get the contents of an input box using Javascript?<\/strong>\r\n\r\n<strong>Ans:\u00a0<\/strong>Use the &#8220;value&#8221; property.\r\nvar myValue = window.document.getElementById(&#8220;MyTextBox&#8221;).value;\r\n\r\n<hr \/>\r\n\r\n<strong>38) How to determine the state of a checkbox using Javascript?<\/strong>\r\n\r\n<strong>Ans:\u00a0<\/strong>var checkedP = window.document.getElementById(&#8220;myCheckBox&#8221;).checked;\r\n\r\n<hr \/>\r\n\r\n<strong>39) How to set the focus in an element using Javascript?<\/strong>\r\n\r\n<strong>Ans:<\/strong>\u00a0How to access an external javascript file that is stored externally and not embedded?\r\nThis can be achieved by using the following tag between head tags or between body tags.\r\nHow to access an external javascript file that is stored externally and not embedded? where abc.js is the external javscript file to be accessed.\r\n\r\n<hr \/>\r\n\r\n<strong>40) What is the difference between an alert box and a confirmation box?<\/strong>\r\n\r\n<strong>Ans:\u00a0<\/strong>An alert box displays only one button which is the OK button whereas the Confirm box displays two buttons namely OK and cancel.\r\n\r\n<hr \/>\r\n\r\n<strong>41) What is a prompt box?<\/strong>\r\n\r\n<strong>Ans:<\/strong>\u00a0A prompt box allows the user to enter input by providing a text box.\r\n\r\n<hr \/>\r\n\r\n<strong>42) Can javascript code be broken in different lines?<\/strong>\r\n\r\n<strong>Ans:<\/strong>\u00a0Breaking is possible within a string statement by using a backslash \\ at the end but not within any other javascript statement.\r\nthat is ,\r\ndocument.write(&#8220;Hello \\ world&#8221;);\r\nis possible but not document.write \\\r\n(&#8220;hello world&#8221;);\r\n\r\n<hr \/>\r\n\r\n<strong>43) Taking a developer\u2019s perspective, do you think that that JavaScript is easy to learn and use?<\/strong>\r\n\r\n<strong>Ans:\u00a0<\/strong>One of the reasons JavaScript has the word &#8220;script&#8221; in it is that as a programming language, the vocabulary of the core language is compact compared to full-fledged programming languages. If you already program in Java or C, you actually have to unlearn some concepts that had been beaten into you. For example, JavaScript is a loosely typed language, which means that a variable doesn&#8217;t care if it&#8217;s holding a string, a number, or a reference to an object; the same variable can even change what type of data it holds while a script runs.\r\nThe other part of JavaScript implementation in browsers that makes it easier to learn is that most of the objects you script are pre-defined for the author, and they largely represent physical things you can see on a page: a text box, an image, and so on. It&#8217;s easier to say, &#8220;OK, these are the things I&#8217;m working with and I&#8217;ll use scripting to make them do such and such,&#8221; instead of having to dream up the user interface, conceive of and code objects, and handle the interaction between objects and users. With scripting, you tend to write a _lot_ less code.\r\n\r\n<hr \/>\r\n\r\n<strong>44) What Web sites do you feel use JavaScript most effectively (i.e., best-in-class examples)? The worst?<\/strong>\r\n\r\n<strong>Ans:\u00a0<\/strong>The best sites are the ones that use JavaScript so transparently, that I&#8217;m not aware that there is any scripting on the page. The worst sites are those that try to impress me with how much scripting is on the page.\r\n\r\n<hr \/>\r\n\r\n<strong>45) How about 2+5+&#8221;8&#8243;?<\/strong>\r\n\r\n<strong>Ans:\u00a0<\/strong>Since 2 and 5 are integers, this is number arithmetic, since 8 is a string, it\u2019s concatenation, so 78 is the result.\r\n\r\n<hr \/>\r\n\r\n<strong>46) What is the difference between SessionState and ViewState?<\/strong>\r\n\r\n<strong>Ans:<\/strong>\u00a0ViewState is specific to a page in a session. Session state refers to user specific data that can be accessed across all pages in the web application.\r\n\r\n<hr \/>\r\n\r\n<strong>47) What does the EnableViewStateMac setting in an aspx page do?<\/strong>\r\n\r\n<strong>Ans:<\/strong>\u00a0Setting EnableViewStateMac=true is a security measure that allows ASP.NET to ensure that the viewstate for a page has not been tampered with. If on Postback, the ASP.NET framework detects that there has been a change in the value of viewstate that was sent to the browser, it raises an error &#8211; Validation of viewstate MAC failed.\r\nUse &lt;%@ Page EnableViewStateMac=&#8221;true&#8221;%&gt; to set it to true (the default value, if this attribute is not specified is also true) in an aspx page.\r\n\r\n<hr \/>\r\n\r\n<strong>48)<\/strong>\u00a0<strong>What and where are the best JavaScript resources on the Web?<\/strong>\r\n\r\n<strong>Ans:\u00a0<\/strong>The Web has several FAQ areas on JavaScript. The best place to start is something called the meta-FAQ [14-Jan-2001 Editor&#8217;s Note: I can&#8217;t point to it anymore, it is broken!], which provides a high-level overview of the JavaScript help available on the Net. As for fact-filled FAQs, I recommend one maintained by Martin Webb and a mini-FAQ that I maintain.\r\n\r\nFor interactive help with specific problems, nothing beats the primary JavaScript Usenet newsgroup, comp.lang.javascript. Depending on my work backlog, I answer questions posted there from time to time. Netscape and Microsoft also have vendor-specific developer discussion groups as well as detailed documentation for the scripting and object model implementations\r\n\r\n<form action=\"https:\/\/asha24.net\/blog\/javascript-interview-questions-and-answers\" name=\"beerForm\">\r\n\r\n<hr \/>\r\n\r\n<strong>49) What looping structures are there in JavaScript?<\/strong>\r\n\r\n<strong>Ans:\u00a0<\/strong>for, while, do-while loops, but no foreach.\r\n\r\n<hr \/>\r\n\r\n<strong>50)\u00a0<\/strong><strong>How to get the contents of an input box using Javascript?<\/strong>\r\n\r\n<strong>Ans:\u00a0<\/strong>Use the &#8220;value&#8221; property.\r\n\r\nvar myValue = window.document.getElementById(&#8220;MyTextBox&#8221;).value\r\n\r\n<hr \/>\r\n\r\n<strong>51)\u00a0<\/strong><strong>Taking a developer\u2019s perspective, do you think that that JavaScript is easy to learn and use?<\/strong>\r\n\r\n<strong>Ans:<\/strong>\u00a0One of the reasons JavaScript has the word &#8220;script&#8221; in it is that as a programming language, the vocabulary of the core language is compact compared to full- fledged programming languages. If you already program in Java or C, you actually have to unlearn some concepts that had been beaten into you.\r\n\r\nFor example, JavaScript is a loosely typed language, which means that a variable doesn&#8217;t care if it&#8217;s holding a string, a number, or a reference to an object; the same variable can even change what type of data it holds while a script runs.\r\n\r\nThe other part of JavaScript implementation in browsers that makes it easier to learn is that most of the objects you script are pre-defined for the author, and they largely represent physical things you can see on a page: a text box, an image, and so on. It&#8217;s easier to say, &#8220;OK, these are the things I&#8217;m working with and I&#8217;ll use scripting to make them do such and such,&#8221; instead of having to dream up the user interface, conceive of and code objects, and handle the interaction between objects and users. With scripting, you tend to write a _lot_ less code.\r\n\r\n<hr \/>\r\n\r\n<strong>59)\u00a0<\/strong><strong>What are undefined and undeclared variables?<\/strong>\r\n\r\n<strong>Ans:<\/strong>\u00a0Undeclared variables are those that are not declared in the program (do not exist at all),trying to read their values gives runtime error.But if undeclared variables are assigned then implicit declaration is done. Undefined variables are those that are not assigned any value but are declared in the program.Trying to read such variables gives special value called undefined value.\r\n\r\n<hr \/>\r\n\r\n<strong>60) How to disable an HTML object ?<\/strong>\r\n\r\n<strong>Ans:\u00a0<\/strong>document.getElementById(&#8220;myObject&#8221;).disabled = true;\r\n\r\nTo write messages to the screen without using &#8220;document.write()&#8221; ?\r\nChanging the contents of an element is a much better solution. When the method showStatus is invoked it will change the content of the span.\r\n&#8230;\r\nfunction showStatus(message) {\r\nvar element = document.getElementById(&#8220;mystatus&#8221;);\r\nelement.textContent = message; \/\/for Firefox\r\nelement.innerHTML = message; \/\/for IE (why can&#8217;t we all just get along?)\r\nreturn true;\r\n}\r\n&#8230;\r\nTest.\r\n&#8230;\r\n\r\n<hr \/>\r\n\r\n<strong>61)<\/strong>\u00a0<strong>What does break and continue statements do?<\/strong>\r\n\r\n<strong>Ans:<\/strong>\u00a0Continue statement continues the current loop (if label not specified) in a new iteration whereas break statement exits the current loop.\r\n\r\n<hr \/>\r\n\r\n<strong>62)\u00a0<\/strong><strong>How to create a function using function constructor?<\/strong>\r\n\r\n<strong>Ans:\u00a0<\/strong>The following example illustrates this It creates a function called square with argument x and returns x multiplied by itself.\r\n\r\nvar square = new Function (&#8220;x&#8221;,&#8221;return x*x&#8221;);\r\n\r\n<\/form>\r\n\r\n<hr \/>\r\n\r\n<strong>63)\u00a0<\/strong><strong>C<\/strong><strong>an JavaScript be used to personalize or tailor a Web site to fit individual users?<\/strong>\r\n\r\n<strong>Ans:<\/strong>\u00a0JavaScript allows a Web page to perform &#8220;if-then&#8221; kinds of decisions based on browser version, operating system, user input, and, in more recent browsers, details about the screen size in which the browser is running. While a server CGI program can make some of those same kinds of decisions, not everyone has access to or the expertise to create CGI programs.\r\n\r\nFor example, an experienced CGI programmer can examine information about the browser whenever a request for a page is made; thus a server so equipped might serve up one page for Navigator users and a different page for Internet Explorer users. Beyond browser and operating system version, a CGI program can&#8217;t know more about the environment.\r\n\r\nBut a JavaScript-enhanced page can instruct the browser to render only certain content based on the browser, operating system, and even the screen size.\r\n\r\nScripting can even go further if the page author desires. For example, the author may include a preference screen that lets the user determine the desired background and text color combination. A script can save this information on the client in a well-regulated local file called a cookie.\r\n\r\nThe next time the user comes to the site, scripts in its pages look to the cookie info and render the page in the color combination selected previously. The server is none the wiser, nor does it have to store any visitor-specific information.\r\n\r\n<hr \/>\r\n\r\n<strong>64) How to create a popup warning box<\/strong>\r\n\r\n<strong>Ans:<\/strong>\u00a0alert(&#8216;Warning: Please enter an integer between 0 and 100.&#8217;);\r\n\r\n<hr \/>\r\n\r\n<strong>65) How to create a confirmation box?<\/strong>\r\n\r\n<strong>Ans:<\/strong>\u00a0confirm(&#8220;Do you really want to launch the missile?&#8221;);\r\n\r\n<hr \/>\r\n\r\n<strong>66) How to create an input box?<\/strong>\r\n\r\n<strong>Ans:<\/strong>\u00a0prompt(&#8220;What is your temperature?&#8221;);\r\n\r\n<hr \/>\r\n\r\n<strong>67)\u00a0<\/strong><strong>Are Java and JavaScript the Same?<\/strong>\r\n\r\n<strong>Ans:<\/strong>\u00a0No.java and javascript are two different languages.\r\n\r\nJava is a powerful object &#8211; oriented programming language like C++,C whereas Javascript is a client-side scripting language with some limitations.\r\n\r\n<hr \/>\r\n\r\n<strong>68) How to getting values from cookies to set widgets?<\/strong>\r\n\r\n<strong>Ans:<\/strong>\r\n\r\nfunction getCookieData(labelName) {\r\n\/\/from Danny Goodman\r\nvar labelLen = labelName.length;\r\n\/\/ read cookie property only once for speed\r\nvar cookieData = document.cookie;\r\nvar cLen = cookieData.length;\r\nvar i = 0;\r\nvar cEnd;\r\nwhile (i &lt; cLen) {\r\nvar j = i + labelLen;\r\nif (cookieData.substring(i,j) == labelName) {\r\ncEnd = cookieData.indexOf(&#8220;;&#8221;,j);\r\nif (cEnd == -1) {\r\ncEnd = cookieData.length;\r\n}\r\nreturn unescape(cookieData.substring(j+1, cEnd));\r\n}\r\ni++;\r\n}\r\nreturn &#8220;&#8221;;\r\n}\r\n\r\n\/\/init() is called from the body tag onload function.\r\nfunction init() {\r\nsetValueFromCookie(&#8220;brand&#8221;);\r\nsetValueFromCookie(&#8220;market&#8221;);\r\nsetValueFromCookie(&#8220;measure&#8221;);\r\n}\r\n\r\nfunction setValueFromCookie(widget) {\r\nif( getCookieData(widget) != &#8220;&#8221;) {\r\ndocument.getElementById(widget).value = getCookieData(widget);\r\n}\r\n}\r\n\r\n\/\/if you name your cookies the widget ID, you can use the following helper function\r\nfunction setCookie(widget) {\r\ndocument.cookie = widget + &#8220;=&#8221; +\r\nescape(document.getElementById(widget).value) + getExpirationString();\r\n}\r\n\r\n<hr \/>\r\n\r\n<strong>69) How to change style on an element?<\/strong>\r\n\r\n<strong>Ans:\u00a0<\/strong>Between CSS and javascript is a weird symmetry. CSS style rules are layed on top of the DOM. The CSS property names like &#8220;font-weight&#8221; are transliterated into &#8220;myElement.style.fontWeight&#8221;. The class of an element can be swapped out. For example:\r\ndocument.getElementById(&#8220;myText&#8221;).style.color = &#8220;green&#8221;;\r\ndocument.getElementById(&#8220;myText&#8221;).style.fontSize = &#8220;20&#8221;;\r\n-or-\r\ndocument.getElementById(&#8220;myText&#8221;).className = &#8220;regular&#8221;;\r\n\r\n<hr \/>\r\n\r\n<strong>70)\u00a0<\/strong><strong>What is the difference between a web-garden and a web-farm?<\/strong>\r\n\r\n<strong>Ans:\u00a0<\/strong><em>Web-garden<\/em>\u00a0&#8211; An IIS6.0 feature where you can configure an application pool as a web-garden and also specify the number of worker processes for that pool. It can help improve performance in some cases.\r\n\r\n<em>Web-farm<\/em>\u00a0&#8211; a general term referring to a cluster of physically separate machines, each running a web-server for scalability and performance (contrast this with web-garden which refers to multiple processes on one single physical machine).\r\n\r\n<hr \/>\r\n\r\n<strong>71)\u00a0<\/strong><strong>What is the difference between SessionState and ViewState?<\/strong>\r\n\r\n<strong>Ans:<\/strong>\u00a0ViewState is specific to a page in a session. Session state refers to user specific data that can be accessed across all pages in the web application.\r\n\r\n<hr \/>\r\n\r\n<strong>72) How to make elements invisible ?<\/strong>\r\n\r\n<strong>Ans:<\/strong>\u00a0Change the &#8220;visibility&#8221; attribute of the style object associated with your element. Remember that a hidden element still takes up space, use &#8220;display&#8221; to make the space disappear as well.\r\n\r\nif ( x == y) {\r\nmyElement.style.visibility = &#8216;visible&#8217;;\r\n} else {\r\nmyElement.style.visibility = &#8216;hidden&#8217;;\r\n}\r\n\r\n<hr \/>\r\n\r\n<strong>73) How to set the cursor to wait ?<\/strong>\r\n\r\n<strong>Ans:<\/strong>\u00a0In theory, we should cache the current state of the cursor and then put it back to its original state.\r\ndocument.body.style.cursor = &#8216;wait&#8217;;\r\n\/\/do something interesting and time consuming\r\ndocument.body.style.cursor = &#8216;auto&#8217;;\r\n\r\n<hr \/>\r\n\r\n<strong>74) How to reload the current page ?<\/strong>\r\n\r\n<strong>Ans:<\/strong>\u00a0window.location.reload(true);\r\n\r\n<hr \/>\r\n\r\n<strong>75)\u00a0<\/strong><strong>What does the term sticky session mean in a web-farm scenario? Why would you use a sticky session? What is the potential disadvantage of using a sticky session?<\/strong>\r\n\r\n<strong>Ans:<\/strong>\u00a0Sticky session refers to the feature of many commercial load balancing solutions for web-farms to route the requests for a particular session to the same physical machine that serviced the first request for that session. This is mainly used to ensure that a in-proc session is not lost as a result of requests for a session being routed to different servers. Since requests for a user are always routed to the same machine that first served the request for that session, sticky sessions can cause uneven load distribution across servers.\r\n\r\n<hr \/>\r\n\r\n<strong>76) How to convert a string to a number using JavaScript?<\/strong>\r\n\r\n<strong>Ans:\u00a0<\/strong>You can use the parseInt() and parseFloat() methods. Notice that extra letters following a valid number are ignored, which is kinda wierd but convenient at times.\r\nparseInt(&#8220;100&#8221;) ==&gt; 100\r\nparseFloat(&#8220;98.6&#8221;) ==&gt; 98.6\r\nparseFloat(&#8220;98.6 is a common temperature.&#8221;) ==&gt; 98.6\r\nparseInt(&#8220;aa&#8221;) ==&gt; Nan \/\/Not a Number\r\nparseInt(&#8220;aa&#8221;,16) ==&gt; 170 \/\/you can supply a radix or base\r\n\r\n<hr \/>\r\n\r\n<strong>77) How to convert numbers to strings using JavaScript?<\/strong>\r\n\r\n<strong>Ans:\u00a0<\/strong>You can prepend the number with an empty string\r\nvar mystring = &#8220;&#8221;+myinteger;\r\nor\r\nvar mystring = myinteger.toString();\r\nYou can specify a base for the conversion,\r\nvar myinteger = 14;\r\nvar mystring = myinteger.toString(16);\r\n\r\nmystring will be &#8220;e&#8221;.\r\n\r\n<hr \/>\r\n\r\n<strong>78) How to test for bad numbers using JavaScript?<\/strong>\r\n\r\n<strong>Ans:\u00a0<\/strong>The global method, &#8220;isNaN()&#8221; can tell if a number has gone bad.\r\nvar temperature = parseFloat(myTemperatureWidget.value);\r\nif(!isNaN(temperature)) {\r\nalert(&#8220;Please enter a valid temperature.&#8221;);\r\n}\r\n\r\n<hr \/>\r\n\r\n<strong>79) What&#8217;s Math Constants and Functions using JavaScript?<\/strong>\r\n\r\n<strong>Ans:<\/strong>\u00a0The Math object contains useful constants such as Math.PI, Math.E\r\nMath also has a zillion helpful functions.\r\nMath.abs(value); \/\/absolute value\r\nMath.max(value1, value2); \/\/find the largest\r\nMath.random() \/\/generate a decimal number between 0 and 1\r\nMath.floor(Math.random()*101) \/\/generate a decimal number between 0 and 100\r\n\r\n<hr \/>\r\n\r\n<strong>80) What&#8217;s the Date object using JavaScript?<\/strong>\r\n\r\n<strong>Ans:<\/strong>\u00a0Time inside a date object is stored as milliseconds since Jan 1, 1970.\r\nnew Date(06,01,02) \/\/ produces &#8220;Fri Feb 02 1906 00:00:00 GMT-0600 (Central Standard Time)&#8221;\r\nnew Date(06,01,02).toLocaleString() \/\/ produces &#8220;Friday, February 02, 1906 00:00:00&#8221;\r\nnew Date(06,01,02) &#8211; new Date(06,01,01) \/\/ produces &#8220;86400000&#8221;\r\n\r\n<hr \/>\r\n\r\n<strong>81) What does the delete operator do?<\/strong>\r\n\r\n<strong>Ans:\u00a0<\/strong>The delete operator is used to delete all the variables and objects used in the program ,but it does not delete variables declared with var keyword.\r\n\r\n<hr \/>\r\n\r\n<strong>82)<\/strong>\u00a0<strong>What does undefined value mean in javascript?<\/strong>\r\n\r\n<strong>Ans:<\/strong>\u00a0Undefined value means the variable used in the code doesn&#8217;t exist or is not assigned any value or the property doesn&#8217;t exist.\r\n\r\n<hr \/>\r\n\r\n<strong>83) What does break and continue statements do?<\/strong>\r\n\r\n<strong>Ans:<\/strong>\u00a0Continue statement continues the current loop (if label not specified) in a new iteration whereas break statement exits the current loop.\r\n\r\n<hr \/>\r\n\r\n<strong>84) How to create a function using function constructor?<\/strong>\r\n\r\n<strong>Ans:<\/strong>\u00a0The following example illustrates this\r\nIt creates a function called square with argument x and returns x multiplied by itself.\r\nvar square = new Function (&#8220;x&#8221;,&#8221;return x*x&#8221;);\r\n\r\n[\/et_pb_text][\/et_pb_column][\/et_pb_row][\/et_pb_section][et_pb_section bb_built=&#8221;1&#8243; prev_background_color=&#8221;#000000&#8243;][et_pb_row][et_pb_column type=&#8221;4_4&#8243;][et_pb_team_member _builder_version=&#8221;3.0.106&#8243; name=&#8221;Nitesh&#8221; position=&#8221;Author&#8221; facebook_url=&#8221;&#8221; twitter_url=&#8221;&#8221; google_url=&#8221;&#8221; linkedin_url=&#8221;&#8221; background_layout=&#8221;light&#8221; body_font=&#8221;Titillium Web||||||||&#8221; body_font_size=&#8221;16&#8243; body_font_size_last_edited=&#8221;on|desktop&#8221; header_font=&#8221;Titillium Web|700|||||||&#8221; image_url=&#8221;https:\/\/asha24.net\/blog\/\/wp-content\/uploads\/2018\/03\/Nitesh.gif&#8221;]\r\n\r\nBonjour. A curious dreamer enchanted by various languages, I write towards making technology seem fun here at Asha24.\r\n\r\n[\/et_pb_team_member][\/et_pb_column][\/et_pb_row][\/et_pb_section]\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":4,"featured_media":48050,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"on","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"categories":[57],"tags":[58],"class_list":["post-48049","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-interview-questions","tag-interview-questions"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v17.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>JavaScript Interview Questions and Answers - Asha24 Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/asha24.net\/blog\/javascript-interview-questions-and-answers\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"JavaScript Interview Questions and Answers - Asha24 Blog\" \/>\n<meta property=\"og:url\" content=\"https:\/\/asha24.net\/blog\/javascript-interview-questions-and-answers\/\" \/>\n<meta property=\"og:site_name\" content=\"Asha24 Blog\" \/>\n<meta property=\"article:published_time\" content=\"2018-01-30T06:04:09+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-02-04T04:01:32+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/asha24.net\/blog\/wp-content\/uploads\/2018\/03\/javascript-interview-questions-and-answers-1.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"459\" \/>\n\t<meta property=\"og:image:height\" content=\"344\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Mahesh\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"25 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/asha24.net\/blog\/#website\",\"url\":\"https:\/\/asha24.net\/blog\/\",\"name\":\"Asha24 Blog\",\"description\":\"Dedication Towards Learning\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/asha24.net\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/asha24.net\/blog\/javascript-interview-questions-and-answers\/#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/asha24.net\/blog\/wp-content\/uploads\/2018\/03\/javascript-interview-questions-and-answers-1.jpg\",\"contentUrl\":\"https:\/\/asha24.net\/blog\/wp-content\/uploads\/2018\/03\/javascript-interview-questions-and-answers-1.jpg\",\"width\":459,\"height\":344},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/asha24.net\/blog\/javascript-interview-questions-and-answers\/#webpage\",\"url\":\"https:\/\/asha24.net\/blog\/javascript-interview-questions-and-answers\/\",\"name\":\"JavaScript Interview Questions and Answers - Asha24 Blog\",\"isPartOf\":{\"@id\":\"https:\/\/asha24.net\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/asha24.net\/blog\/javascript-interview-questions-and-answers\/#primaryimage\"},\"datePublished\":\"2018-01-30T06:04:09+00:00\",\"dateModified\":\"2023-02-04T04:01:32+00:00\",\"author\":{\"@id\":\"https:\/\/asha24.net\/blog\/#\/schema\/person\/f6167b78bbaddfc399ae1154cd5b6759\"},\"breadcrumb\":{\"@id\":\"https:\/\/asha24.net\/blog\/javascript-interview-questions-and-answers\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/asha24.net\/blog\/javascript-interview-questions-and-answers\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/asha24.net\/blog\/javascript-interview-questions-and-answers\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/asha24.net\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JavaScript Interview Questions and Answers\"}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/asha24.net\/blog\/#\/schema\/person\/f6167b78bbaddfc399ae1154cd5b6759\",\"name\":\"Mahesh\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/asha24.net\/blog\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/085c03e75ffb51af2509c1cfad9c7d78b30236d43a008db2e46f96e2f40c67fc?s=96&d=wavatar&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/085c03e75ffb51af2509c1cfad9c7d78b30236d43a008db2e46f96e2f40c67fc?s=96&d=wavatar&r=g\",\"caption\":\"Mahesh\"},\"url\":\"https:\/\/asha24.net\/blog\/author\/mahesh\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"JavaScript Interview Questions and Answers - Asha24 Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/asha24.net\/blog\/javascript-interview-questions-and-answers\/","og_locale":"en_US","og_type":"article","og_title":"JavaScript Interview Questions and Answers - Asha24 Blog","og_url":"https:\/\/asha24.net\/blog\/javascript-interview-questions-and-answers\/","og_site_name":"Asha24 Blog","article_published_time":"2018-01-30T06:04:09+00:00","article_modified_time":"2023-02-04T04:01:32+00:00","og_image":[{"width":459,"height":344,"url":"https:\/\/asha24.net\/blog\/wp-content\/uploads\/2018\/03\/javascript-interview-questions-and-answers-1.jpg","path":"\/home\/reviews981\/public_html\/asha24.net\/blog\/wp-content\/uploads\/2018\/03\/javascript-interview-questions-and-answers-1.jpg","size":"full","id":48050,"alt":"","pixels":157896,"type":"image\/jpeg"}],"twitter_card":"summary_large_image","twitter_misc":{"Written by":"Mahesh","Est. reading time":"25 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebSite","@id":"https:\/\/asha24.net\/blog\/#website","url":"https:\/\/asha24.net\/blog\/","name":"Asha24 Blog","description":"Dedication Towards Learning","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/asha24.net\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"ImageObject","@id":"https:\/\/asha24.net\/blog\/javascript-interview-questions-and-answers\/#primaryimage","inLanguage":"en-US","url":"https:\/\/asha24.net\/blog\/wp-content\/uploads\/2018\/03\/javascript-interview-questions-and-answers-1.jpg","contentUrl":"https:\/\/asha24.net\/blog\/wp-content\/uploads\/2018\/03\/javascript-interview-questions-and-answers-1.jpg","width":459,"height":344},{"@type":"WebPage","@id":"https:\/\/asha24.net\/blog\/javascript-interview-questions-and-answers\/#webpage","url":"https:\/\/asha24.net\/blog\/javascript-interview-questions-and-answers\/","name":"JavaScript Interview Questions and Answers - Asha24 Blog","isPartOf":{"@id":"https:\/\/asha24.net\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/asha24.net\/blog\/javascript-interview-questions-and-answers\/#primaryimage"},"datePublished":"2018-01-30T06:04:09+00:00","dateModified":"2023-02-04T04:01:32+00:00","author":{"@id":"https:\/\/asha24.net\/blog\/#\/schema\/person\/f6167b78bbaddfc399ae1154cd5b6759"},"breadcrumb":{"@id":"https:\/\/asha24.net\/blog\/javascript-interview-questions-and-answers\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/asha24.net\/blog\/javascript-interview-questions-and-answers\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/asha24.net\/blog\/javascript-interview-questions-and-answers\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/asha24.net\/blog\/"},{"@type":"ListItem","position":2,"name":"JavaScript Interview Questions and Answers"}]},{"@type":"Person","@id":"https:\/\/asha24.net\/blog\/#\/schema\/person\/f6167b78bbaddfc399ae1154cd5b6759","name":"Mahesh","image":{"@type":"ImageObject","@id":"https:\/\/asha24.net\/blog\/#personlogo","inLanguage":"en-US","url":"https:\/\/secure.gravatar.com\/avatar\/085c03e75ffb51af2509c1cfad9c7d78b30236d43a008db2e46f96e2f40c67fc?s=96&d=wavatar&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/085c03e75ffb51af2509c1cfad9c7d78b30236d43a008db2e46f96e2f40c67fc?s=96&d=wavatar&r=g","caption":"Mahesh"},"url":"https:\/\/asha24.net\/blog\/author\/mahesh\/"}]}},"_links":{"self":[{"href":"https:\/\/asha24.net\/blog\/wp-json\/wp\/v2\/posts\/48049","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/asha24.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/asha24.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/asha24.net\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/asha24.net\/blog\/wp-json\/wp\/v2\/comments?post=48049"}],"version-history":[{"count":4,"href":"https:\/\/asha24.net\/blog\/wp-json\/wp\/v2\/posts\/48049\/revisions"}],"predecessor-version":[{"id":52190,"href":"https:\/\/asha24.net\/blog\/wp-json\/wp\/v2\/posts\/48049\/revisions\/52190"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/asha24.net\/blog\/wp-json\/wp\/v2\/media\/48050"}],"wp:attachment":[{"href":"https:\/\/asha24.net\/blog\/wp-json\/wp\/v2\/media?parent=48049"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/asha24.net\/blog\/wp-json\/wp\/v2\/categories?post=48049"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/asha24.net\/blog\/wp-json\/wp\/v2\/tags?post=48049"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}