{"id":6587,"date":"2022-01-17T22:30:41","date_gmt":"2022-01-17T17:00:41","guid":{"rendered":"https:\/\/blog.guvi.in\/?p=6587"},"modified":"2025-12-29T17:44:48","modified_gmt":"2025-12-29T12:14:48","slug":"javascript-questions-towards-better-interviews","status":"publish","type":"post","link":"https:\/\/www.guvi.in\/blog\/javascript-questions-towards-better-interviews\/","title":{"rendered":"45 JavaScript Questions Towards Better Interviews"},"content":{"rendered":"\n<p>&#8216;JavaScript Interview questions&#8217;- this phrase is one of the most searched Google queries. And Why?<\/p>\n\n\n\n<p>JavaScript is the most popular programming language that every web browser understands! And therefore, it is the main ingredient on every web developer&#8217;s plate. Yes! The scripting language, which was born with the then-in-vogue programming language JAVA, is now the core language that makes the web browsers all the more interactive. <\/p>\n\n\n\n<p>Little wonder that we meet here on this page to uncover the essential JavaScript Interview questions. Above all, a web developer role is one of the most interesting and creative job roles that keep your pockets happy too! <\/p>\n\n\n\n<p>Not only web development, many other jobs in Information Security, Software Development, WordPress Development, etc., demand JavaScript developers. <\/p>\n\n\n\n<p>So, not taking any more time of your&#8217;s let&#8217;s dive deep into the JavaScript questions!<\/p>\n\n\n\n<p>Let&#8217;s start with some overview questions. These are the brushing-up questions. Above all, you would encounter them in a more or less casual way. Everyone surely knows them but fails to put them into words. You need to know how to answer them, that&#8217;s all. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Quick<strong> <\/strong>Answer<\/h2>\n\n\n\n<p>JavaScript interviews focus on core concepts, hands-on coding problems, and real-world logic. You should be comfortable with variables, functions, scope, closures, arrays, objects, asynchronous JavaScript, ES6 features, and writing clean code to solve interview-level problems.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">JAVASCRIPT OVERVIEW QUESTIONS<\/h2>\n\n\n\n<p><em>Before diving into the next section, ensure you&#8217;re solid on full-stack development essentials like front-end frameworks, back-end technologies, and database management. If you are looking for a detailed full-stack development career program, you can join HCL GUVI\u2019s <a href=\"https:\/\/www.guvi.in\/zen-class\/full-stack-development-course\/?utm_source=blog&amp;utm_medium=hyperlink&amp;utm_campaign=42+JavaScript+Questions+Towards+Better+Interviews\" data-type=\"link\" data-id=\"https:\/\/www.guvi.in\/zen-class\/full-stack-development-course\/?utm_source=blog&amp;utm_medium=organic&amp;utm_campaign=42+JavaScript+Questions+Towards+Better+Interviews\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>Full Stack Development Course<\/strong><\/a> with Placement Assistance. You will be able to master the <a href=\"https:\/\/www.guvi.in\/blog\/guide-for-mern-stack\/\" target=\"_blank\" rel=\"noreferrer noopener\">MERN stack<\/a> (MongoDB, Express.js, React, Node.js) and build real-life projects.<\/em> <\/p>\n\n\n\n<p><em>Additionally, if you want to explore JavaScript through a self-paced course, try HCL GUVI\u2019s <strong><a href=\"https:\/\/www.guvi.in\/courses\/web-development\/advanced-javascript\/?utm_source=blog&amp;utm_medium=hyperlink&amp;utm_campaign=42+JavaScript+Questions+Towards+Better+Interviews\" data-type=\"link\" data-id=\"https:\/\/www.guvi.in\/courses\/web-development\/advanced-javascript\/?utm_source=blog&amp;utm_medium=organic&amp;utm_campaign=42+JavaScript+Questions+Towards+Better+Interviews\" target=\"_blank\" rel=\"noreferrer noopener\">JavaScript certification course<\/a>. <\/strong><\/em><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong><span class=\"has-inline-color has-vivid-red-color\">1<\/span>. <span class=\"has-inline-color has-vivid-red-color\">What is JavaScript?<\/span><\/strong><\/h3>\n\n\n\n<div class=\"wp-block-group has-background is-layout-flow wp-block-group-is-layout-flow\" style=\"background-color:#ebeced\"><div class=\"wp-block-group__inner-container\">\n<p>Ans. JavaScript is the world&#8217;s most popular programming language. Above all, it is the programming language mainly used in the Web Development domain, and is commonly implemented for creating web pages. <\/p>\n\n\n\n<p>JavaScript is a <\/p>\n\n\n\n<ul>\n<li>high-level, <\/li>\n\n\n\n<li>dynamic, <\/li>\n\n\n\n<li>object-based, and <\/li>\n\n\n\n<li>interpreted programming language. <\/li>\n<\/ul>\n\n\n\n<p>JavaScript was invented by Brendan Eich in 1995. It was developed for Netscape 2 and became the ECMA-262 standard in 1997.<\/p>\n\n\n\n<p>It is commonly used for creating web pages. JavaScript allows us to add dynamic behavior to the webpage and add special effects to it. On websites, JavaScript is mainly used for validation purposes.<\/p>\n\n\n\n<p>It is widely used, supported &amp; accessible even to beginners.<\/p>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"> <span class=\"has-inline-color has-vivid-red-color\"><strong>2. How to implement JavaScript<\/strong>?<\/span><\/h3>\n\n\n\n<div class=\"wp-block-group has-background is-layout-flow wp-block-group-is-layout-flow\" style=\"background-color:#ebeced\"><div class=\"wp-block-group__inner-container\">\n<p>Ans. JavaScript can be implemented in three different ways, namely<\/p>\n\n\n\n<p>\u2022 Embedding code<br>\u2022 Inline code<br>\u2022 External file<\/p>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\"><strong>3. How do you write JavaScript? <\/strong><\/mark><\/h3>\n\n\n\n<div class=\"wp-block-group has-background is-layout-flow wp-block-group-is-layout-flow\" style=\"background-color:#ebeced\"><div class=\"wp-block-group__inner-container\">\n<p><br>Ans. JavaScript code is embedded in the HTML. The client browsers can then interpret and run them.<\/p>\n\n\n\n<ul>\n<li>JavaScript code is case-sensitive.<\/li>\n\n\n\n<li>You can ignore the white space between words and tabs.<\/li>\n\n\n\n<li>Also, you can ignore the line breaks except within a statement.<\/li>\n\n\n\n<li>JavaScript statements end with a semicolon.<\/li>\n<\/ul>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\"><strong>4. What are Objects in JavaScript?<\/strong><\/mark><\/h3>\n\n\n\n<p class=\"has-background\" style=\"background-color:#ebeced\">Ans. In JavaScript, an object is a standalone entity with properties and a type. Compare it with a cup, <\/p>\n\n\n\n<div class=\"wp-block-group has-background is-layout-flow wp-block-group-is-layout-flow\" style=\"background-color:#ebeced\"><div class=\"wp-block-group__inner-container\">\n<p>for example. A cup is an object with properties. A cup has a color, a design, a weight, etc.<\/p>\n\n\n\n<p>JavaScript properties: In the same way, JavaScript objects can have properties, which define their characteristics<\/p>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong><span class=\"has-inline-color has-vivid-red-color\">5. What are JavaScript Events?<\/span><\/strong><\/h3>\n\n\n\n<div class=\"wp-block-group has-background is-layout-flow wp-block-group-is-layout-flow\" style=\"background-color:#ebeced\"><div class=\"wp-block-group__inner-container\">\n<p>Ans. The change in the state of an object is known as an Event. In HTML, various events represent that some activity is performed by the user or by the browser.<\/p>\n\n\n\n<p>When JavaScript code is included in HTML, JavaScript reacts to these events and allows the execution. This process of reacting to the events is called Event Handling. Thus, JS handles the HTML events via Event Handlers.<\/p>\n\n\n\n<p>Common events are:<\/p>\n\n\n\n<div class=\"wp-block-columns has-background is-layout-flex wp-container-6 wp-block-columns-is-layout-flex\" style=\"background-color:#bfdaf3\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:100%\">\n<p><strong><span class=\"has-inline-color has-black-color\">\u2022 onLoad &#8211; occurs when a page loads in a browser<br>\u2022 onUnload &#8211; occurs just before the user exits a page<br>\u2022 onMouseOver &#8211; occurs when you point to an object<br>\u2022 onMouseOut &#8211; occurs when you point away from an object<br>\u2022 onSubmit &#8211; occurs when you submit a form<br>\u2022 onClick &#8211; occurs when an object is clicked<\/span><\/strong><\/p>\n<\/div>\n<\/div>\n\n\n\n<p><br>JavaScript\u2019s interaction with HTML is handled through events that occur when the user or the browser manipulates a page. When the page loads, it is called an event. When the user clicks a button, that click is an event. <\/p>\n\n\n\n<p>Other examples include events like pressing any key, closing a window, resizing a window, etc. <\/p>\n\n\n\n<p><br>Developers can use these events to execute JavaScript-coded responses, which cause buttons to close windows, messages to be displayed to users, data to be validated, and virtually any other type of response imaginable. Events are a part of the Document Object Model (DOM) Level 3 and every HTML element contains a set of events that can trigger JavaScript Code.<\/p>\n<\/div><\/div>\n\n\n\n<p>Let&#8217;s move ahead. With more interesting JavaScript Questions. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Theoretical JavaScript Questions<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\"><strong>6. Can you name any two programming paradigms important for JavaScript app developers?<\/strong><\/mark><\/h3>\n\n\n\n<div class=\"wp-block-group has-background is-layout-flow wp-block-group-is-layout-flow\" style=\"background-color:#ebeced\"><div class=\"wp-block-group__inner-container\">\n<p>JavaScript is a multi-paradigm language, supporting imperative\/procedural programming along with OOP (Object-Oriented Programming) and functional programming. JavaScript supports OOP with prototypal inheritance.<\/p>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\"><strong>7. What is functional programming?<\/strong><\/mark><\/h3>\n\n\n\n<div class=\"wp-block-group has-background is-layout-flow wp-block-group-is-layout-flow\" style=\"background-color:#ebeced\"><div class=\"wp-block-group__inner-container\">\n<p>Functional programming produces programs by composing mathematical functions. Furthermore, it avoids shared state &amp; mutable data.<\/p>\n\n\n\n<p>Lisp (specified in 1958) was among the first languages to support functional programming and was heavily inspired by the lambda calculus. Functional programming is an essential concept in JavaScript (one of the two pillars of JavaScript). <\/p>\n\n\n\n<p>Several common functional utilities were added to JavaScript in ES5.<br>The core focus lies on:<\/p>\n\n\n\n<p>&#8211; Function purity <\/p>\n\n\n\n<p>&#8211; Avoiding side-effects <\/p>\n\n\n\n<p>&#8211; Simple function composition<\/p>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong><span class=\"has-inline-color has-vivid-red-color\">8. What is the difference between classical inheritance and prototypal inheritance?<\/span><\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/miro.medium.com\/max\/1200\/1*dianRzNAQevG4-ZXUfxpDg.png\" alt=\"Decoding the Prototypal Inheritance in JavaScript: Everything you need to  know! | by Gaurav Chaudhary | Medium\" title=\"\"><figcaption class=\"wp-element-caption\"><em><sub><strong>Taken from Medium<\/strong><\/sub><\/em><\/figcaption><\/figure>\n\n\n\n<div class=\"wp-block-group has-background is-layout-flow wp-block-group-is-layout-flow\" style=\"background-color:#ebeced\"><div class=\"wp-block-group__inner-container\">\n<p><strong>Class Inheritance:<\/strong> Instances inherit from classes (like a blueprint &#8211; a description of the class), and create sub-class relationships: hierarchical class taxonomies. Instances are typically instantiated via constructor functions with the new keyword. In short, Class inheritance may or may not use the class keyword from ES6.<\/p>\n\n\n\n<p><br><strong>Prototypal Inheritance: <\/strong>Instances inherit directly from other objects. Instances are typically instantiated via factory functions or Object.create(). Instances may be composed of many different objects, allowing for easy selective inheritance.<\/p>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\"><strong>9. When is prototypal inheritance an appropriate choice?<\/strong><\/mark><\/h3>\n\n\n\n<div class=\"wp-block-group has-background is-layout-flow wp-block-group-is-layout-flow\" style=\"background-color:#ebeced\"><div class=\"wp-block-group__inner-container\">\n<p>There is more than one type of prototypal inheritance:<br>\u2022 Delegation (i.e., the prototype chain).<br>\u2022 Concatenative (i.e. mixins, Object.assign()).<br>\u2022 Functional (Not to be confused with functional programming. A function used to create a closure for private state\/encapsulation).<\/p>\n\n\n\n<p><br>Each type of prototypal inheritance has its own set of use cases. However, all of them are equally useful in their ability to enable composition. That will create has-a or uses-a or can-do relationships as opposed to the is-a relationship created with class inheritance.<\/p>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong><span class=\"has-inline-color has-vivid-red-color\">10. What is asynchronous programming, and why is it important in JavaScript?<\/span><\/strong><\/h3>\n\n\n\n<div class=\"wp-block-group has-background is-layout-flow wp-block-group-is-layout-flow\" style=\"background-color:#ebeced\"><div class=\"wp-block-group__inner-container\">\n<p><strong>Synchronous programming&nbsp;<\/strong>means that, barring conditionals and function calls, code is executed sequentially from top to bottom, blocking on long-running tasks such as network requests and disk I\/O. <\/p>\n\n\n\n<p>Whereas&nbsp;<strong>Asynchronous programming<\/strong>&nbsp;means that the engine runs in an event loop. When a blocking operation is needed, the request is started, and the code keeps running without blocking for the result. <\/p>\n\n\n\n<p>When the response is ready, an interrupt is fired, which causes an event handler to be run, where the control flow continues. In this way, a single program thread can handle many concurrent operations. <\/p>\n\n\n\n<p><strong>User interfaces<\/strong> are asynchronous by nature and spend most of their time waiting for user input to interrupt the event loop and trigger event handlers. Node is asynchronous by default. That means the server works in much the same way, waiting in a loop for a network request. And accepting more incoming requests while the first one is being handled. <\/p>\n\n\n\n<p>This is important in JavaScript because it is a very natural fit for user interface code and very beneficial to performance on the server.<\/p>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">11. What are JavaScript data types?<\/mark><\/h3>\n\n\n\n<div class=\"wp-block-group has-background is-layout-flow wp-block-group-is-layout-flow\" style=\"background-color:#ebeced\"><div class=\"wp-block-group__inner-container\">\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"726\" src=\"http:\/\/blog.guvi.in\/wp-content\/uploads\/2022\/01\/Data-Types-in-Javascript-1024x726.png\" alt=\"What are JavaScript data types?\" class=\"wp-image-7203\" srcset=\"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2022\/01\/Data-Types-in-Javascript-1024x726.png 1024w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2022\/01\/Data-Types-in-Javascript-300x213.png 300w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2022\/01\/Data-Types-in-Javascript-768x545.png 768w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2022\/01\/Data-Types-in-Javascript-1536x1090.png 1536w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2022\/01\/Data-Types-in-Javascript.png 1748w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" title=\"\"><\/figure>\n\n\n\n<p>In JavaScript, there are <\/p>\n\n\n\n<p><strong>3 Primary Data Types: <\/strong><\/p>\n\n\n\n<p>String, <\/p>\n\n\n\n<p>Number, <\/p>\n\n\n\n<p>Boolean.<\/p>\n\n\n\n<p><strong>Then, 4 Composite Data Types  <\/strong><\/p>\n\n\n\n<p>Object<\/p>\n\n\n\n<p>Functions<\/p>\n\n\n\n<p>Date, <\/p>\n\n\n\n<p>Array.<\/p>\n\n\n\n<p><strong>And, two data types that cannot contain any values: <\/strong><\/p>\n\n\n\n<p>Null and <\/p>\n\n\n\n<p>Undefined<\/p>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">12. What is the difference between &#8220;==&#8221; and &#8220;===&#8221;?<\/mark><\/h3>\n\n\n\n<div class=\"wp-block-group has-background is-layout-flow wp-block-group-is-layout-flow\" style=\"background-color:#ebeced\"><div class=\"wp-block-group__inner-container\">\n<p>&#8220;==&#8221; checks only for equality in value, whereas &#8220;===&#8221; is a stricter equality test and returns false if either the value or the type of the two variables are different. <\/p>\n\n\n\n<p>So, the second option needs both the value and the type to be the same for the operands.<\/p>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">13. What is an undefined value in JavaScript?<\/mark><\/h3>\n\n\n\n<div class=\"wp-block-group has-background is-layout-flow wp-block-group-is-layout-flow\" style=\"background-color:#ebeced\"><div class=\"wp-block-group__inner-container\">\n<p>Undefined value means the:<br>\u2022 The variable used in the code doesn\u2019t exist<br>\u2022 Furthermore, the variable is not assigned to any value<br>\u2022 Property doesn\u2019t exist<\/p>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">14. What are the different types of errors in JavaScript?<\/mark><\/h3>\n\n\n\n<div class=\"wp-block-group has-background is-layout-flow wp-block-group-is-layout-flow\" style=\"background-color:#ebeced\"><div class=\"wp-block-group__inner-container\">\n<p>There are three types of errors:<br><strong>\u2022 Load time errors: <\/strong><\/p>\n\n\n\n<p>Errors that come up when loading a web page, like improper syntax errors, are known as load-time errors, and it generated the errors dynamically.<\/p>\n\n\n\n<p><br>\u2022<strong> Run-time errors: <\/strong><\/p>\n\n\n\n<p>Errors that come due to the misuse of the command inside the <a href=\"https:\/\/www.guvi.in\/blog\/html-tutorial-guide-for-web-development\/\" target=\"_blank\" rel=\"noreferrer noopener\">HTML language<\/a>.<\/p>\n\n\n\n<p><br>\u2022<strong> Logical Errors: <\/strong><\/p>\n\n\n\n<p>These are errors that occur due to the wrong logic performed on a function.<\/p>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">15. Define <a href=\"https:\/\/www.guvi.in\/blog\/event-delegation-and-bubbling-in-javascript\/\" target=\"_blank\" rel=\"noreferrer noopener\">event bubbling<\/a><\/mark><\/h3>\n\n\n\n<div class=\"wp-block-group has-background is-layout-flow wp-block-group-is-layout-flow\" style=\"background-color:#ebeced\"><div class=\"wp-block-group__inner-container\">\n<p>JavaScript allows DOM elements to be nested inside each other. In such a case, if the handler of the child is clicked, the handler of the parent will also work as if it were clicked too.<\/p>\n<\/div><\/div>\n\n\n\n<p>Further ahead, moving on to more general JavaScript Questions. These are very interesting at the same time, and very likely to be asked JavaScript Interview Questions. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">General Questions <\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">16. What is the \u2018this\u2019 keyword in JavaScript? <\/mark><\/h3>\n\n\n\n<div class=\"wp-block-group has-background is-layout-flow wp-block-group-is-layout-flow\" style=\"background-color:#ebeced\"><div class=\"wp-block-group__inner-container\">\n<p>In JavaScript, this keyword refers to the object it belongs to. <\/p>\n\n\n\n<p><em><strong>This<\/strong><\/em> has different values depending on where it is used:<\/p>\n\n\n\n<p>=&gt; In a method, this refers to the owner object.<\/p>\n\n\n\n<p>=&gt; Alone, this refers to the global object. <\/p>\n\n\n\n<p>=&gt; In a function, in strict mode, this is undefined <\/p>\n\n\n\n<p>=&gt; While, in a function, this refers to the global object.<\/p>\n\n\n\n<p>=&gt; In an event, this keyword refers to the element that received the event. <\/p>\n\n\n\n<p>=&gt; Methods like call( ) and apply( ) will assign this to any object. <\/p>\n\n\n\n<p>=&gt; In an object, this refers to the \u201cowner\u201d of the method.<\/p>\n<\/div><\/div>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">17. What is the difference between ViewState and SessionState? <\/mark><\/h3>\n\n\n\n<div class=\"wp-block-group has-background is-layout-flow wp-block-group-is-layout-flow\" style=\"background-color:#ebeced\"><div class=\"wp-block-group__inner-container\">\n<p>ViewState is specific to a page in a session. <\/p>\n\n\n\n<p>SessionState is specific to user-specific data that can be accessed across all pages in the web application. <\/p>\n<\/div><\/div>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">18. Does JavaScript support automatic type conversion? <\/mark><\/h3>\n\n\n\n<div class=\"wp-block-group has-background is-layout-flow wp-block-group-is-layout-flow\" style=\"background-color:#ebeced\"><div class=\"wp-block-group__inner-container\">\n<p>Yes, JavaScript does support automatic type conversion. It is the common way of type conversion used by JavaScript developers. <\/p>\n<\/div><\/div>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">19. How can you read and write a file using JavaScript? <\/mark><\/h3>\n\n\n\n<div class=\"wp-block-group has-background is-layout-flow wp-block-group-is-layout-flow\" style=\"background-color:#ebeced\"><div class=\"wp-block-group__inner-container\">\n<p>There are two ways to read and write a file using JavaScript<\/p>\n\n\n\n<p> \u2022 Using JavaScript extensions <\/p>\n\n\n\n<p>\u2022 Using a web page and Active X objects <\/p>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">20. How can you read and write a file using JavaScript? <\/mark><\/h3>\n\n\n\n<div class=\"wp-block-group has-background is-layout-flow wp-block-group-is-layout-flow\" style=\"background-color:#ebeced\"><div class=\"wp-block-group__inner-container\">\n<p>The parseInt() function is used to convert numbers between different bases. parseInt() takes the string to be converted as its first parameter. And the second parameter is the base of the given string. <\/p>\n<\/div><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">JavaScript Interview Questions <\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">21. What is the use of Void(0)? <\/mark><\/h3>\n\n\n\n<div class=\"wp-block-group has-background is-layout-flow wp-block-group-is-layout-flow\" style=\"background-color:#ebeced\"><div class=\"wp-block-group__inner-container\">\n<p>Void(0) is used to prevent the page from refreshing. We pass the parameter &#8220;zero&#8221; when calling. Void(0) is used to call another method without refreshing the page. <\/p>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">22. What are JavaScript Cookies? <\/mark><\/h3>\n\n\n\n<div class=\"wp-block-group has-background is-layout-flow wp-block-group-is-layout-flow\" style=\"background-color:#ebeced\"><div class=\"wp-block-group__inner-container\">\n<p>A cookie is&nbsp;<strong>an amount of information that persists<\/strong>&nbsp;between the server-side and the client-side. A web browser stores this information at the time of browsing. <\/p>\n\n\n\n<p>A cookie contains the information as a string, generally in the form of a name-value pair separated by semicolons.<\/p>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">23. How to target a particular frame, from a hyperlink, in JavaScript? <\/mark><\/h3>\n\n\n\n<div class=\"wp-block-group has-background is-layout-flow wp-block-group-is-layout-flow\" style=\"background-color:#ebeced\"><div class=\"wp-block-group__inner-container\">\n<p>This can be done by including the name of the required frame in the hyperlink using the \u2018target\u2019 attribute. <\/p>\n\n\n\n<p><strong>There are two approaches mainly followed:<\/strong><\/p>\n\n\n\n<p>Target frame without using JavaScript. \/\/ Target attribute has iframe name as its value.  <\/p>\n\n\n\n<p>&lt; a href = &#8220;#&#8221; target = &#8220;frame-name&#8221; &gt;Link&lt;\/ a &gt; \/\/Name attribute has name of the iframe. <\/p>\n\n\n\n<p>And the other is Target frame using JavaScript: \/\/General syntax. <\/p>\n\n\n\n<p>document.getElementById( &#8220;frame-id&#8221; ).src = &#8220;url&#8221;;<\/p>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\"><div class=\"wp-block-group__inner-container\">\n<h3 class=\"wp-block-heading\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">24. Explain the role of deferred scripts in JavaScript?<\/mark><\/h3>\n\n\n\n<p><\/p>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-group has-background is-layout-flow wp-block-group-is-layout-flow\" style=\"background-color:#ebeced\"><div class=\"wp-block-group__inner-container\">\n<p>By default, the parsing of the HTML code, during page loading, is paused until the script has not stopped executing. That means, if the server is slow or the script is particularly heavy, then the webpage is displayed with a delay. <\/p>\n\n\n\n<p>While using Deferred, scripts delay execution of the script till the HTML parser is running. This reduces the loading time of web pages and they get displayed faster. <\/p>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">25. What does a timer do and how would you implement one? <\/mark><\/h3>\n\n\n\n<div class=\"wp-block-group has-background is-layout-flow wp-block-group-is-layout-flow\" style=\"background-color:#ebeced\"><div class=\"wp-block-group__inner-container\">\n<p>Setting timers allows you to execute your code at predefined times or intervals. <\/p>\n\n\n\n<p>This can be achieved through two main methods: <\/p>\n\n\n\n<p><strong>setInterval();<\/strong> and <\/p>\n\n\n\n<p><strong>setTimeout()<\/strong>; <\/p>\n\n\n\n<p>setInterval() accepts a function and a specified number of milliseconds. ex) setInterval(function(){alert(&#8220;Hello, World!&#8221;),10000) will alert the &#8220;Hello, World!&#8221; function every 10 seconds. <\/p>\n\n\n\n<p>Whereas, setTimeout() also accepts a function, followed by milliseconds. setTimeout() will only execute the function once after the specified amount of time, and will not reoccur in intervals.<\/p>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">26. Explain the concept of unobtrusive Javascript? <\/mark><\/h3>\n\n\n\n<div class=\"wp-block-group has-background is-layout-flow wp-block-group-is-layout-flow\" style=\"background-color:#ebeced\"><div class=\"wp-block-group__inner-container\">\n<p>Unobtrusive JavaScript is basically a JavaScript methodology that seeks to overcome browser inconsistencies by separating page functionality from structure. <\/p>\n\n\n\n<p>The basic premise of unobtrusive JavaScript is that page functionality should be maintained even when JavaScript is unavailable on a user\u2019s browser. <\/p>\n<\/div><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Some Tricky JavaScript Questions<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">27. Is false false?<br><\/mark><\/h3>\n\n\n\n<div class=\"wp-block-group has-background is-layout-flow wp-block-group-is-layout-flow\" style=\"background-color:#ebeced\"><div class=\"wp-block-group__inner-container\">\n<p>No. Because it\u2019s a string with a length greater than 0. Only empty strings can be considered false.<\/p>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><br><span class=\"has-inline-color has-vivid-red-color\">28. Is \u2019 \u2019 false?<\/span><\/h3>\n\n\n\n<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\"><div class=\"wp-block-group__inner-container\">\n<p class=\"has-background\" style=\"background-color:#ebeced\"><br><strong>No.  <\/strong><\/p>\n\n\n\n<p class=\"has-white-background-color has-background\">Because it\u2019s not an empty string. There is a white space in it.<br><\/p>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">29. Is Boolean(function(){}) true or false?<br><\/mark><\/h3>\n\n\n\n<p class=\"has-background\" style=\"background-color:#ebeced\"><strong>true<\/strong> <\/p>\n\n\n\n<p class=\"has-white-background-color has-background\"> If you pass a true value to Boolean, it will be true.<br><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">30. What is 2 + true?<\/mark><\/h3>\n\n\n\n<div class=\"wp-block-group has-background is-layout-flow wp-block-group-is-layout-flow\" style=\"background-color:#ebeced\"><div class=\"wp-block-group__inner-container\">\n<p><br><strong>3<\/strong> <\/p>\n\n\n\n<p>The plus operator between a number and a boolean or two booleans will convert a boolean to a number. Hence, true converts to 1, and you get the result of 2+1.<\/p>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><br><span class=\"has-inline-color has-vivid-red-color\">31. What is 6+9?<\/span><\/h3>\n\n\n\n<div class=\"wp-block-group has-background is-layout-flow wp-block-group-is-layout-flow\" style=\"background-color:#ebeced\"><div class=\"wp-block-group__inner-container\">\n<p><strong>69 <\/strong><\/p>\n\n\n\n<p> If one of the operands of the plus (+) operator is a string it will convert the other number or boolean to string and perform concatenation. For the same reason, &#8220;2&#8221;+true will return &#8220;2true&#8221;.<\/p>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><br><span class=\"has-inline-color has-vivid-red-color\">32. What is the value of +dude?<\/span><\/h3>\n\n\n\n<p class=\"has-background\" style=\"background-color:#ebeced\"><br><strong>NaN. <\/strong><\/p>\n\n\n\n<p class=\"has-white-background-color has-background\">The plus (+) operator in front of a string is a unary operator that will try to convert the string to a number. Here, JavaScript will fail to convert the &#8220;dude&#8221; to a number and will produce NaN.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><br><span class=\"has-inline-color has-vivid-red-color\">33. If you have var y = 1, x = y = typeof x; What is the value of x?<\/span><\/h3>\n\n\n\n<p class=\"has-background\" style=\"background-color:#ebeced\">&#8220;undefined&#8221;.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><br><span class=\"has-inline-color has-vivid-red-color\">34. If var a = (2, 3, 5); what is the value of a?<\/span><\/h3>\n\n\n\n<p class=\"has-background\" style=\"background-color:#ebeced\"><strong>5<\/strong> <\/p>\n\n\n\n<p class=\"has-white-background-color has-background\">The comma operator evaluates each of its operands (from left to right) and returns the value of the last operand.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><br><span class=\"has-inline-color has-vivid-red-color\">35. What is -5%2?<br><\/span><\/h3>\n\n\n\n<p class=\"has-background\" style=\"background-color:#ebeced\"><strong>-1<\/strong><\/p>\n\n\n\n<p class=\"has-white-background-color has-background\">The result of remainder always gets the symbol of the first operand.<br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Code Output Questions<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">36. What will the code below output to the console and why?<\/mark><\/h3>\n\n\n\n<div class=\"wp-block-group has-background is-layout-flow wp-block-group-is-layout-flow\" style=\"background-color:#ebeced\"><div class=\"wp-block-group__inner-container\">\n<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\"><div class=\"wp-block-group__inner-container\">\n<p class=\"has-background\" style=\"background-color:#bfdaf3\">(function(){<br>var a = b = 3;<br>})();<br>console.log(&#8220;a defined? &#8221; + (typeof a !== \u2019undefined\u2019));<br>console.log(&#8220;b defined? &#8221; + (typeof b !== \u2019undefined\u2019));<\/p>\n<\/div><\/div>\n\n\n\n<p><br>Answer:<br>Since both a and b are defined within the enclosing scope of the function. And since the line, they are on begins with the var keyword, most JavaScript developers would expect typeof a and typeof b to both be undefined in the above example.<\/p>\n\n\n\n<p>However, that is not the case. The issue here is that most developers incorrectly understand the statement var a = b = 3; to be shorthand for:<br>var b =3; var a =b;<\/p>\n\n\n\n<p>But in fact, var a =b =3; is actually shorthand for:<\/p>\n\n\n\n<p>b =3; var a =b;<br>As a result (if you are not using strict mode), the output of the code snippet would be:<\/p>\n\n\n\n<p><br>a defined? false<br>b defined? true<\/p>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">37. What will the code below output to the console and why?<\/mark><\/h3>\n\n\n\n<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\"><div class=\"wp-block-group__inner-container\">\n<div class=\"wp-block-group has-background is-layout-flow wp-block-group-is-layout-flow\" style=\"background-color:#ebeced\"><div class=\"wp-block-group__inner-container\">\n<p class=\"has-background\" style=\"background-color:#bfdaf3\"><br>var myObject = {<br>foo: &#8220;bar&#8221;,<br>func: function() {<br>var self = this;<br>console.log(&#8220;outer func: this.foo = &#8221; + this.foo);<br>console.log(&#8220;outer func: self.foo = &#8221; + self.foo);<br>(function() {<br>console.log(&#8220;inner func: this.foo = &#8221; + this.foo);<br>console.log(&#8220;inner func: self.foo = &#8221; + self.foo);<br>}());<br>JavaScript Interview Questions 10 \/ 28<br>}<br>};<br>myObject.func();<\/p>\n\n\n\n<p><br>Answer:<\/p>\n\n\n\n<p>The above code will output the following to the console:<br>outer func: this.foo = bar<br>outer func: self.foo = bar<br>inner func: this.foo = undefined<br>inner func: self.foo = bar<\/p>\n\n\n\n<p><br>In the outer function, both this and self refer to myObject and therefore both can properly reference and access foo. <\/p>\n\n\n\n<p><br>Again, in the inner function, though, this no longer refers to myObject. As a result, this. foo is undefined in the inner function, whereas the reference to the local variable self remains in scope and is accessible there. <\/p>\n\n\n\n<p>(Prior to ECMA 5, this in the inner function would refer to the global window object; whereas, as of ECMA 5, this in the inner function would be undefined.)<\/p>\n<\/div><\/div>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">38.  What will the code below output? Explain your answer.<\/mark><\/h3>\n\n\n\n<div class=\"wp-block-group has-background is-layout-flow wp-block-group-is-layout-flow\" style=\"background-color:#ebeced\"><div class=\"wp-block-group__inner-container\">\n<p class=\"has-background\" style=\"background-color:#bfdaf3\"><br>console.log(0.1 + 0.2);<br>console.log(0.1 + 0.2 == 0.3);<\/p>\n\n\n\n<p>Answer:<br>An educated answer to this question would simply be: &#8220;You can\u2019t be sure. it might print out &#8220;0.3&#8221; and &#8220;true&#8221;, or it might not.<\/p>\n\n\n\n<p>Numbers in JavaScript are all treated with floating point precision, and as such, may not always yield the expected results.&#8221;<\/p>\n\n\n\n<p>The example provided above is a classic case that demonstrates this issue. Surprisingly, the output here is:<\/p>\n\n\n\n<p><br><strong>0.30000000000000004<\/strong><\/p>\n\n\n\n<p><br><strong>false<\/strong><\/p>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">39.  What will be the output when the following code is executed? Explain.<br><\/mark><\/h3>\n\n\n\n<div class=\"wp-block-group has-background is-layout-flow wp-block-group-is-layout-flow\" style=\"background-color:#ebeced\"><div class=\"wp-block-group__inner-container\">\n<div class=\"wp-block-group has-background is-layout-flow wp-block-group-is-layout-flow\" style=\"background-color:#bfdaf3\"><div class=\"wp-block-group__inner-container\">\n<p>console.log(false == \u20190\u2019)<br>console.log(false === \u20190\u2019)<br><\/p>\n<\/div><\/div>\n\n\n\n<p>Answer:<br>Firstly, the code will output:<br><strong>true<br>false<\/strong><\/p>\n\n\n\n<p>In JavaScript, there are two sets of equality operators.<\/p>\n\n\n\n<p>Here, the triple-equal operator === behaves like any traditional equality operator would. So, it evaluates to true if the two expressions on either of its sides have the same type and the same value. <\/p>\n\n\n\n<p>The double-equal operator, however, tries to coerce the values before comparing them. It is therefore generally good practice to use the === rather<br>than ==. The same holds true for !== vs !=.<\/p>\n<\/div><\/div>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">40. What will the code below output to the console and why?<\/mark><\/h3>\n\n\n\n<div class=\"wp-block-group has-background is-layout-flow wp-block-group-is-layout-flow\" style=\"background-color:#ebeced\"><div class=\"wp-block-group__inner-container\">\n<div class=\"wp-block-group has-background is-layout-flow wp-block-group-is-layout-flow\" style=\"background-color:#bfdaf3\"><div class=\"wp-block-group__inner-container\">\n<p>var arr1 = &#8220;john&#8221;.split(\u2019\u2019);<br>var arr2 = arr1.reverse();<br>var arr3 = &#8220;jones&#8221;.split(\u2019\u2019);<br>arr2.push(arr3);<br>console.log(&#8220;array 1: length=&#8221; + arr1.length + &#8221; last=&#8221; + arr1.slice(-1));<br>console.log(&#8220;array 2: length=&#8221; + arr2.length + &#8221; last=&#8221; + arr2.slice(-1));<\/p>\n<\/div><\/div>\n\n\n\n<p><br>Answer:<br>The logged output will be:<br>&#8220;array 1: length=5 last=j,o,n,e,s&#8221;<br>&#8220;array 2: length=5 last=j,o,n,e,s&#8221;<\/p>\n\n\n\n<p><br>arr1 and arr2 are the same after the above code is executed for the following reasons:<br>Calling an array object\u2019s reverse() method doesn\u2019t only return the array in reverse order, it also reverses the order of the array itself (i.e., in this case, arr1).<\/p>\n\n\n\n<p><br>The reverse() method returns a reference to the array itself (i.e., in this case, arr1). As a result, arr2 is simply a reference to (rather than a copy of) arr1. Therefore, when anything is done to arr2 (i.e., when we invoke arr2.push(arr3);), arr1 will be affected as well since arr1 and arr2 are simply references to the same object. <\/p>\n<\/div><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">CODE In JavaScript<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">41. Implement <strong><em>moveLeft<\/em><\/strong> animation<\/mark><\/h3>\n\n\n\n<p><br>Answer:<br>Firstly, use setInterval that will place the element to the left position by some pixels every 10ms. <\/p>\n\n\n\n<p>Then, you will see the element moving towards the desired position. When you call setInterval, it returns a timeId. After reaching the respective location, you have to clear the time interval. So that function will not be called again and again every 10ms.<\/p>\n\n\n\n<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\"><div class=\"wp-block-group__inner-container\">\n<p class=\"has-background\" style=\"background-color:#bfdaf3\"><br>function moveLeft(elem, distance) {<br>var left = 0;<br>function frame() {<br>left++;<br>elem.style.left = left + \u2019px\u2019;<br>if (left == distance)<br>clearInterval(timeId)<br>}<br>var timeId = setInterval(frame, 10); \/\/ draw every 10ms<br>}<\/p>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">42. Reverse a String Without Using Built-in Methods<\/mark><\/h3>\n\n\n\n<div class=\"wp-block-group has-background is-layout-constrained wp-block-group-is-layout-constrained\" style=\"background-color:#bfdaf3\"><div class=\"wp-block-group__inner-container\">\n<p>function reverseString(str) {<br>let reversed = &#8220;&#8221;;<br>for (let i = str.length &#8211; 1; i &gt;= 0; i&#8211;) {<br>reversed += str[i];<br>}<br>return reversed;<br>}<\/p>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">43. Find the Largest Number in an Array<\/mark><\/h3>\n\n\n\n<div class=\"wp-block-group is-layout-constrained wp-block-group-is-layout-constrained\"><div class=\"wp-block-group__inner-container\">\n<div class=\"wp-block-group has-background is-layout-constrained wp-block-group-is-layout-constrained\" style=\"background-color:#bfdaf3\"><div class=\"wp-block-group__inner-container\">\n<p>function findLargest(arr) {<br>let max = arr[0];<br>for (let i = 1; i &lt; arr.length; i++) { if (arr[i] &gt; max) {<br>max = arr[i];<br>}<br>}<br>return max;<br>}<\/p>\n<\/div><\/div>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">44. Implement Debounce Function<\/mark><\/h3>\n\n\n\n<div class=\"wp-block-group has-background is-layout-constrained wp-block-group-is-layout-constrained\" style=\"background-color:#bfdaf3\"><div class=\"wp-block-group__inner-container\">\n<p>function debounce(fn, delay) {<br>let timer;<br>return function (\u2026args) {<br>clearTimeout(timer);<br>timer = setTimeout(() =&gt; fn.apply(this, args), delay);<br>};<br>}<\/p>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">45. Implement cache to a recursive <em>fibonacci <\/em>function<\/mark><\/h3>\n\n\n\n<p>Answer:  If fibonacci is already calculated it is served from the global memo array otherwise it is calculated. <\/p>\n\n\n\n<div class=\"wp-block-group has-background is-layout-flow wp-block-group-is-layout-flow\" style=\"background-color:#bfdaf3\"><div class=\"wp-block-group__inner-container\">\n<p>var memo = []; <\/p>\n\n\n\n<p>function _fibonacci(n) { <\/p>\n\n\n\n<p>if(memo[n]) { <\/p>\n\n\n\n<p>return memo[n];<\/p>\n\n\n\n<p> } <\/p>\n\n\n\n<p>else if (n &lt; 2) { <\/p>\n\n\n\n<p>return 1; <\/p>\n\n\n\n<p>}<\/p>\n\n\n\n<p>else { <\/p>\n\n\n\n<p>fibonacci(n-2) + fibonacci(n-1); <\/p>\n\n\n\n<p>} <\/p>\n\n\n\n<p>}<\/p>\n<\/div><\/div>\n\n\n\n<div style=\"background-color: #099f4e; border: 3px solid #110053; border-radius: 12px; padding: 18px 22px; color: #FFFFFF; font-size: 18px; font-family: Montserrat, Helvetica, sans-serif; line-height: 1.6; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); max-width: 750px; margin: 22px auto;\">\n  <h3 style=\"margin-top: 0; font-size: 22px; font-weight: 700; color: #ffffff;\">\ud83d\udca1 Did You Know?<\/h3>\n  <ul style=\"padding-left: 20px; margin: 10px 0;\">\n    <li>Many JavaScript interview questions are designed to test how the code works internally, not just the final output.<\/li>\n    <li>Coding questions often combine multiple concepts like scope, closures, and asynchronous behavior in a single problem.<\/li>\n    <li>Interviewers value clear problem-solving steps and readable code more than complex one-line solutions.<\/li>\n  <\/ul>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Wrapping Up<\/h2>\n\n\n\n<p>So, these are 42 questions towards better JavaScript Programming. <\/p>\n\n\n\n<p>To clarify, the questions are taken from the book JavaScript Interview Questions &amp; Answers, Boosting <span style=\"margin: 0px; padding: 0px;\">Your&nbsp;<a href=\"https:\/\/www.guvi.in\/blog\/career-opportunities-in-web-development\/\" target=\"_blank\" rel=\"noopener\">Web Development<\/a><\/span><a href=\"https:\/\/www.guvi.in\/blog\/career-opportunities-in-web-development\/\" target=\"_blank\" rel=\"noreferrer noopener\"> Career<\/a>, Fabio CIMO. Found it very helpful, so sharing it across. <\/p>\n\n\n\n<p><em>Kickstart your Full Stack Development journey by enrolling in HCL GUVI&#8217;s certified <a href=\"https:\/\/www.guvi.in\/zen-class\/full-stack-development-course\/?utm_source=blog&amp;utm_medium=hyperlink&amp;utm_campaign=42+JavaScript+Questions+Towards+Better+Interviews\" data-type=\"link\" data-id=\"https:\/\/www.guvi.in\/zen-class\/full-stack-development-course\/?utm_source=blog&amp;utm_medium=organic&amp;utm_campaign=42+JavaScript+Questions+Towards+Better+Interviews\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>Full Stack Development Course<\/strong><\/a><strong> <\/strong>with Placement Assistance, where you will master the MERN stack (MongoDB, Express.js, React, Node.js) and build interesting real-life projects. This program is crafted by our team of experts to help you upskill and assist you in placements.<\/em><\/p>\n\n\n\n<p><em>If you want to explore JavaScript through a self-paced course, try HCL GUVI\u2019s <strong><a href=\"https:\/\/www.guvi.in\/courses\/web-development\/advanced-javascript\/?utm_source=blog&amp;utm_medium=hyperlink&amp;utm_campaign=42+JavaScript+Questions+Towards+Better+Interviews\" target=\"_blank\" rel=\"noreferrer noopener\">JavaScript certification course<\/a>.<\/strong><\/em><\/p>\n\n\n\n<div class=\"wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>&#8216;JavaScript Interview questions&#8217;- this phrase is one of the most searched Google queries. And Why? JavaScript is the most popular programming language that every web browser understands! And therefore, it is the main ingredient on every web developer&#8217;s plate. Yes! The scripting language, which was born with the then-in-vogue programming language JAVA, is now the [&hellip;]<\/p>\n","protected":false},"author":65,"featured_media":7219,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[719,13],"tags":[],"views":"13077","authorinfo":{"name":"Jebasta","url":"https:\/\/www.guvi.in\/blog\/author\/jebasta\/"},"thumbnailURL":"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2022\/01\/Javascript-questions-1-300x140.png","jetpack_featured_media_url":"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2022\/01\/Javascript-questions-1.png","_links":{"self":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts\/6587"}],"collection":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/users\/65"}],"replies":[{"embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/comments?post=6587"}],"version-history":[{"count":30,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts\/6587\/revisions"}],"predecessor-version":[{"id":97862,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts\/6587\/revisions\/97862"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/media\/7219"}],"wp:attachment":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/media?parent=6587"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/categories?post=6587"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/tags?post=6587"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}