{"id":25585977,"date":"2024-06-20T17:31:53","date_gmt":"2024-06-20T12:01:53","guid":{"rendered":"https:\/\/entri.app\/blog\/?p=25585977"},"modified":"2024-06-20T17:33:02","modified_gmt":"2024-06-20T12:03:02","slug":"javascript-coding-interview-questions-and-answers","status":"publish","type":"post","link":"https:\/\/entri.app\/blog\/javascript-coding-interview-questions-and-answers\/","title":{"rendered":"JavaScript coding interview questions and Answers"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_79_2 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-69d3708214cfb\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-69d3708214cfb\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/entri.app\/blog\/javascript-coding-interview-questions-and-answers\/#JavaScript_Interview_Questions_for_Freshers\" >JavaScript Interview Questions for Freshers<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/entri.app\/blog\/javascript-coding-interview-questions-and-answers\/#JavaScript_Interview_Questions_for_Experienced\" >JavaScript Interview Questions for Experienced<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/entri.app\/blog\/javascript-coding-interview-questions-and-answers\/#Tips_to_prepare_for_a_JavaScript_coding_interview\" >Tips to prepare for a JavaScript coding interview\u00a0<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/entri.app\/blog\/javascript-coding-interview-questions-and-answers\/#Red_Flags\" >Red Flags<\/a><\/li><\/ul><\/nav><\/div>\n<p>JavaScript, made by Brendan Eich in 1995, is one of the foremost broadly utilized web advancement dialects. It was planned to construct energetic web pages at first. A script could be a JS program which will be included to the HTML of any web page. When the page loads, these scripts execute consequently.<\/p>\n<p>A dialect that was initially outlined to construct energetic web pages may presently be run on the server and on nearly any gadget that has the JavaScript Engine installed.<\/p>\n<p>After HTML and CSS, JavaScript is the third greatest web innovation. JavaScript may be a scripting language which will be utilized to build online and versatile apps, web servers, diversions, and more. JavaScript is an object-oriented programming dialect that&#8217;s used to produce websites and applications. It was made with the purposeful of being utilized in a browser. Indeed nowadays, the server-side form of JavaScript known as Node.js may be utilized to make online and portable apps, real-time applications, online gushing applications, and videogames.\u00a0Javascript systems, frequently known as inbuilt libraries, may be utilized to develop desktop and versatile programs. Engineers may spare a parcel of time on dull programming occupations by utilizing these code libraries, permitting them to center on the generation work of development.<\/p>\n<p style=\"text-align: center\"><strong><a class=\"in-cell-link\" href=\"https:\/\/entri.app\/course\/full-stack-developer-course\/\" target=\"_blank\" rel=\"noopener\">Experience the power of our full stack development course with a free demo \u2013 enroll now!<\/a><\/strong><\/p>\n<h2><span class=\"ez-toc-section\" id=\"JavaScript_Interview_Questions_for_Freshers\"><\/span><strong>JavaScript Interview Questions for Freshers<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<section id=\"different-data-types-present-in-javascript\" class=\"ibpage-article-header\">\n<h3><strong>1. What are the different data types present in javascript?<\/strong><\/h3>\n<article class=\"ibpage-article\">To find out the type of a JavaScript variable, we can use the typeof operator.<br \/>\n<strong>1. Primitive types<\/strong><\/p>\n<ul>\n<li><strong>String\u00a0<\/strong>&#8211;\u00a0 It represents a string of characters and is written with double quotes. A string can be represented with either single quotes or double quotes.<\/li>\n<\/ul>\n<p>Example :<\/p>\n<pre><code class=\"language-javascript hljs\"><span class=\"hljs-keyword\">var<\/span> str = <span class=\"hljs-string\">\"Vivek Singh Bisht\"<\/span>; <span class=\"hljs-comment\">\/\/using double quotes<\/span>\r\n<span class=\"hljs-keyword\">var<\/span> str2 = <span class=\"hljs-string\">'John Doe'<\/span>; <span class=\"hljs-comment\">\/\/using single quotes<\/span><\/code><\/pre>\n<ul>\n<li><strong>Number\u00a0<\/strong>&#8211; It represents a number and can be written with or without decimal places.<\/li>\n<\/ul>\n<p>Example :<\/p>\n<pre><code class=\"language-javascript hljs\"><span class=\"hljs-keyword\">var<\/span> x = <span class=\"hljs-number\">3<\/span>; <span class=\"hljs-comment\">\/\/without decimal<\/span>\r\n<span class=\"hljs-keyword\">var<\/span> y = <span class=\"hljs-number\">3.6<\/span>; <span class=\"hljs-comment\">\/\/with decimal<\/span><\/code><\/pre>\n<ul>\n<li><strong>BigInt\u00a0<\/strong>-This data type is used to store numbers that exceed the limits of the Number data type. It can store large integers and is represented by adding &#8220;n&#8221; to an integer.<\/li>\n<\/ul>\n<p>Example :<\/p>\n<pre><code class=\"language-javascript hljs\"><span class=\"hljs-keyword\">var<\/span> bigInteger =  <span class=\"hljs-number\">234567890123456789012345678901234567890<\/span>;<\/code><\/pre>\n<ul>\n<li><strong>Boolean\u00a0<\/strong>&#8211; It represents a logical entity and can only have two values: true or false. Booleans are often used for conditional testing.<\/li>\n<\/ul>\n<p>Example :<\/p>\n<pre><code class=\"language-javascript hljs\"><span class=\"hljs-keyword\">var<\/span> a = <span class=\"hljs-number\">2<\/span>;\r\n<span class=\"hljs-keyword\">var<\/span> b =  <span class=\"hljs-number\">3<\/span>;\r\n<span class=\"hljs-keyword\">var<\/span> c =  <span class=\"hljs-number\">2<\/span>;\r\n(a == b) <span class=\"hljs-comment\">\/\/ returns false<\/span>\r\n(a == c) <span class=\"hljs-comment\">\/\/returns true<\/span><\/code><\/pre>\n<ul>\n<li><strong>Undefined\u00a0<\/strong>&#8211; When a variable is declared but not assigned, it has an undefined value and its type is also undetermined.<\/li>\n<\/ul>\n<p>Example :<\/p>\n<pre><code class=\"language-javascript hljs\"><span class=\"hljs-keyword\">var<\/span> x; <span class=\"hljs-comment\">\/\/ value of x is undefined<\/span>\r\n<span class=\"hljs-keyword\">var<\/span> y = <span class=\"hljs-literal\">undefined<\/span>; <span class=\"hljs-comment\">\/\/ we can also set the value of a variable as undefined<\/span><\/code><\/pre>\n<ul>\n<li><strong>Null\u00a0<\/strong>&#8211; It represents a value that does not exist or is invalid.<\/li>\n<\/ul>\n<p>Example :<\/p>\n<pre><code class=\"language-javascript hljs\"><span class=\"hljs-keyword\">var<\/span> z = <span class=\"hljs-literal\">null<\/span>;<\/code><\/pre>\n<ul>\n<li><strong>Symbol\u00a0<\/strong>&#8211; This is a new data type introduced in the ES6 version of javascript.\u00a0It is used to store an anonymous and unique value.<\/li>\n<\/ul>\n<p>Example :<\/p>\n<pre><code class=\"language-javascript hljs\"><span class=\"hljs-keyword\">var<\/span> symbol1 = <span class=\"hljs-built_in\">Symbol<\/span>(<span class=\"hljs-string\">'symbol'<\/span>);<\/code><\/pre>\n<ul>\n<li>typeof\u00a0<strong>of primitive types\u00a0<\/strong>:<\/li>\n<\/ul>\n<pre><code class=\"language-javascript hljs\"><span class=\"hljs-keyword\">typeof<\/span> <span class=\"hljs-string\">\"John Doe\"<\/span> <span class=\"hljs-comment\">\/\/ Returns \"string\"<\/span>\r\n<span class=\"hljs-keyword\">typeof<\/span> <span class=\"hljs-number\">3.14<\/span> <span class=\"hljs-comment\">\/\/ Returns \"number\"<\/span>\r\n<span class=\"hljs-keyword\">typeof<\/span> <span class=\"hljs-literal\">true<\/span> <span class=\"hljs-comment\">\/\/ Returns \"boolean\"<\/span>\r\n<span class=\"hljs-keyword\">typeof<\/span> <span class=\"hljs-number\">234567890123456789012345678901234567890n<\/span> <span class=\"hljs-comment\">\/\/ Returns bigint<\/span>\r\n<span class=\"hljs-keyword\">typeof<\/span> <span class=\"hljs-literal\">undefined<\/span> <span class=\"hljs-comment\">\/\/ Returns \"undefined\"<\/span>\r\n<span class=\"hljs-keyword\">typeof<\/span> <span class=\"hljs-literal\">null<\/span> <span class=\"hljs-comment\">\/\/ Returns \"object\" (kind of a bug in JavaScript)<\/span>\r\n<span class=\"hljs-keyword\">typeof<\/span> <span class=\"hljs-built_in\">Symbol<\/span>(<span class=\"hljs-string\">'symbol'<\/span>) <span class=\"hljs-comment\">\/\/ Returns Symbol<\/span><\/code><\/pre>\n<p><strong>2. Non-primitive types<\/strong><\/p>\n<ul>\n<li>Primitive data types can only store a single value.<br \/>\nTo store multiple complex values, non-primitive data types are used.<\/li>\n<li>Purpose &#8211; Used to store collected data.<\/li>\n<li>Example:<\/li>\n<\/ul>\n<pre><code class=\"language-javascript hljs\"><span class=\"hljs-comment\">\/\/ Collection of data in key-value pairs<\/span>\r\n\r\n<span class=\"hljs-keyword\">var<\/span> obj1 = {\r\n   <span class=\"hljs-attr\">x<\/span>:  <span class=\"hljs-number\">43<\/span>,\r\n   <span class=\"hljs-attr\">y<\/span>:  <span class=\"hljs-string\">\"Hello world!\"<\/span>,\r\n   <span class=\"hljs-attr\">z<\/span>: <span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span>()<\/span>{\r\n      <span class=\"hljs-keyword\">return<\/span> <span class=\"hljs-built_in\">this<\/span>.x;\r\n   }\r\n}\r\n      \r\n<span class=\"hljs-comment\">\/\/ Collection of data as an ordered list<\/span>\r\n     \r\n<span class=\"hljs-keyword\">var<\/span> array1 = [<span class=\"hljs-number\">5<\/span>, <span class=\"hljs-string\">\"Hello\"<\/span>, <span class=\"hljs-literal\">true<\/span>, <span class=\"hljs-number\">4.1<\/span>]; <\/code><\/pre>\n<section id=\"explain-hoisting\" class=\"ibpage-article-header\">\n<h3><strong>2. Explain Hoisting in javascript.<\/strong><\/h3>\n<article class=\"ibpage-article\">Hoisting is the default behavior of javascript where all variable and function declarations are moved to the top. This means that whenever variables and functions are declared, they are moved to the top of the scope. The scope can be both local and global.<br \/>\n<strong>Example 1:<\/strong><\/p>\n<pre><code class=\"language-javascript hljs\">hoistedVariable = <span class=\"hljs-number\">3<\/span>;\r\n<span class=\"hljs-built_in\">console<\/span>.log(hoistedVariable); <span class=\"hljs-comment\">\/\/ outputs 3 even when the variable is declared after it is initialized\t<\/span>\r\n<span class=\"hljs-keyword\">var<\/span> hoistedVariable;<\/code><\/pre>\n<p><strong>Example 2:<\/strong><\/p>\n<pre><code class=\"language-javascript hljs\">hoistedFunction();  <span class=\"hljs-comment\">\/\/ Outputs \" Hello world! \" even when the function is declared after calling<\/span>\r\n\r\n<span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">hoistedFunction<\/span>()<\/span>{ \r\n  <span class=\"hljs-built_in\">console<\/span>.log(<span class=\"hljs-string\">\" Hello world! \"<\/span>);\r\n}\u00a0<\/code><\/pre>\n<p><strong>Example 3:<\/strong><\/p>\n<pre><code class=\"language-javascript hljs\"><span class=\"hljs-comment\">\/\/ Hoisting takes place in the local scope as well<\/span>\r\n<span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">doSomething<\/span>()<\/span>{\r\n  x = <span class=\"hljs-number\">33<\/span>;\r\n  <span class=\"hljs-built_in\">console<\/span>.log(x);\r\n  <span class=\"hljs-keyword\">var<\/span> x;\r\n}\u00a0<\/code><\/pre>\n<p>doSomething(); \/\/ Outputs 33 since the local variable \u201cx\u201d is hoisted inside the local scope<\/p>\n<blockquote><p>Note &#8211; Variable initializations are not hoisted, only variable declarations are hoisted:<\/p><\/blockquote>\n<pre><code class=\"language-javascript hljs\"><span class=\"hljs-keyword\">var<\/span> x;\r\n<span class=\"hljs-built_in\">console<\/span>.log(x); <span class=\"hljs-comment\">\/\/ Outputs \"undefined\" since the initialization of \"x\" is not hoisted<\/span>\r\nx = <span class=\"hljs-number\">23<\/span>;<\/code><\/pre>\n<blockquote><p>Note &#8211; To avoid hoisting, you can run javascript in strict mode by using \u201cuse strict\u201d on top of the code:<\/p><\/blockquote>\n<pre><code class=\"language-javascript hljs\"><span class=\"hljs-meta\">\"use strict\"<\/span>;\r\nx = <span class=\"hljs-number\">23<\/span>; <span class=\"hljs-comment\">\/\/ Gives an error since 'x' is not declared<\/span>\r\n<span class=\"hljs-keyword\">var<\/span> x; <\/code><\/pre>\n<\/article>\n<\/section>\n<section id=\"debugger\" class=\"ibpage-article-header\">\n<h3><strong>3. Why do we use the word \u201cdebugger\u201d in javascript?<\/strong><\/h3>\n<article class=\"ibpage-article\">The browser debugger must be enabled to debug code. The built-in debugger can be enabled and disabled, asking users to report errors. The remaining code will stop executing before moving on to the next line when debugging.<strong><span style=\"color: #212121;font-size: 1.563em\">4. Difference between \u201c == \u201c and \u201c === \u201c operators.<\/span><\/strong><\/article>\n<\/section>\n<section id=\"difference-between-and-operators\" class=\"ibpage-article-header\">\n<article class=\"ibpage-article\">Both are comparison operators.<br \/>\nThe difference between the two operators is that \u201c==\u201d is used to compare values \u200b\u200bwhile \u201c===\u201d is used to compare both value and type.<strong>Example:<\/strong><\/p>\n<pre><code class=\"language-javascript hljs\"><span class=\"hljs-keyword\">var<\/span> x = <span class=\"hljs-number\">2<\/span>;\r\n<span class=\"hljs-keyword\">var<\/span> y = <span class=\"hljs-string\">\"2\"<\/span>;\r\n(x == y)  <span class=\"hljs-comment\">\/\/ Returns true since the value of both x and y is the same<\/span>\r\n(x === y) <span class=\"hljs-comment\">\/\/ Returns false since the typeof x is \"number\" and typeof y is \"string\"<\/span><\/code><\/pre>\n<\/article>\n<\/section>\n<section id=\"difference-between-var-and-let-keyword-in-javascript\" class=\"ibpage-article-header\">\n<h3><strong>5. Difference between var and let keyword in javascript.<\/strong><\/h3>\n<article class=\"ibpage-article\">Some differences are<\/p>\n<ul>\n<li>Since the beginning, the keyword &#8216;var&#8217; has been used in JavaScript programming whereas the keyword &#8216;let&#8217; was added in 2015.<\/li>\n<li>The keyword &#8216;Var&#8217; has functional scope .<\/li>\n<li>At any place in the function, the variable specified with var can be accessed but in &#8216;let&#8217;, the scope of the variable declared with the &#8216;let&#8217; keyword is limited to the block in which it is declared .<\/li>\n<li>Let&#8217;s start with block scope. In ECMAScript 2015, let and const are hoisted but not initialized.<\/li>\n<li>Referencing a variable in a block before declaring it will result in a ReferenceError because the variable is in a &#8220;temporary dead zone&#8221; from the beginning of the block until the declaration is processed.<\/li>\n<\/ul>\n<h3><strong>6. Explain implicit type coercion in javascript.<\/strong><\/h3>\n<p>Implicit type coercion in javascript is to automatically convert a value from one data type to another. This happens when the operands of an expression have different data types.<\/p>\n<ul>\n<li>String coercion<\/li>\n<\/ul>\n<p>String coercion occurs when using the &#8216; + &#8216; operator. When a number is added to a string, the number type is always converted to string type.<\/p>\n<\/article>\n<\/section>\n<section id=\"implicit-type-coercion\" class=\"ibpage-article-header\">\n<article class=\"ibpage-article\">Example 1:<\/p>\n<pre><code class=\"language-javascript hljs\"><span class=\"hljs-keyword\">var<\/span> x = <span class=\"hljs-number\">3<\/span>;\r\n<span class=\"hljs-keyword\">var<\/span> y = <span class=\"hljs-string\">\"3\"<\/span>;\r\nx + y <span class=\"hljs-comment\">\/\/ Returns \"33\" <\/span><\/code><\/pre>\n<p>Example 2:<\/p>\n<pre><code class=\"language-javascript hljs\"><span class=\"hljs-keyword\">var<\/span> x = <span class=\"hljs-number\">24<\/span>;\r\n<span class=\"hljs-keyword\">var<\/span> y = <span class=\"hljs-string\">\"Hello\"<\/span>;\r\nx + y   <span class=\"hljs-comment\">\/\/ Returns \"24Hello\";\u00a0<\/span><\/code><\/pre>\n<blockquote>\n<h4>Note &#8211; \u2018 + \u2018 operator when used to add two numbers, outputs a number. The same \u2018 + \u2018 operator when used to add two strings, outputs the concatenated string:<\/h4>\n<\/blockquote>\n<pre><code class=\"language-javascript hljs\"><span class=\"hljs-keyword\">var<\/span> name = <span class=\"hljs-string\">\"Vivek\"<\/span>;\r\n<span class=\"hljs-keyword\">var<\/span> surname = <span class=\"hljs-string\">\" Bisht\"<\/span>;\r\nname + surname     <span class=\"hljs-comment\">\/\/ Returns \"Vivek Bisht\"\u00a0<\/span><\/code><\/pre>\n<p>Let\u2019s understand both the examples where we have added a number to a string,<\/p>\n<p>When JavaScript sees that the operands of the expression x + y have different types (one is a number and one is a string), it converts the number to a string and then performs the operation. Since after conversion, both variables are of type string, the &#8216; + &#8216; operator creates the concatenated string &#8220;33&#8221; in the first example and &#8220;24Hello&#8221; in the second example.<\/p>\n<blockquote>\n<h4>Note &#8211; Type coercion also takes place when using the \u2018 &#8211; \u2018 operator, but the difference while using \u2018 &#8211; \u2018 operator is that, a string is converted to a number and then subtraction takes place.<\/h4>\n<\/blockquote>\n<pre><code class=\"language-javascript hljs\"><span class=\"hljs-keyword\">var<\/span> x = <span class=\"hljs-number\">3<\/span>;\r\nVar y = <span class=\"hljs-string\">\"3\"<\/span>;\r\nx - y    <span class=\"hljs-comment\">\/\/Returns 0 since the variable y (string type) is converted to a number type<\/span><\/code><\/pre>\n<ul>\n<li><strong>Boolean Coercion<\/strong><\/li>\n<\/ul>\n<p>Boolean coercion occurs using logical operators, ternary operators, if statements, and loop checking. To understand Boolean coercion in if statements and operators, we need to understand the values \u200b\u200btrue and false.<\/p>\n<p>Truthy values are those which will be converted (coerced) to\u00a0<strong>true<\/strong>. Falsy values are those which will be converted to\u00a0<strong>false<\/strong>.<\/p>\n<p>All values except\u00a0<strong>false, 0, 0n, -0, \u201c\u201d, null, undefined, and NaN\u00a0<\/strong>are truthy values.<\/p>\n<p><strong>If statements:<\/strong><\/p>\n<p>Example:<\/p>\n<pre><code class=\"language-javascript hljs\"><span class=\"hljs-keyword\">var<\/span> x = <span class=\"hljs-number\">0<\/span>;\r\n<span class=\"hljs-keyword\">var<\/span> y = <span class=\"hljs-number\">23<\/span>;\r\n        \r\n<span class=\"hljs-keyword\">if<\/span>(x) { <span class=\"hljs-built_in\">console<\/span>.log(x) }   <span class=\"hljs-comment\">\/\/ The code inside this block will not run since the value of x is 0(Falsy)  <\/span>\r\n        \r\n<span class=\"hljs-keyword\">if<\/span>(y) { <span class=\"hljs-built_in\">console<\/span>.log(y) }    <span class=\"hljs-comment\">\/\/ The code inside this block will run since the value of y is 23 (Truthy)<\/span><\/code><\/pre>\n<ul>\n<li><strong>Logical operators:<\/strong><\/li>\n<\/ul>\n<p>Logical operators in JavaScript, unlike operators in other programming languages, do not return true or false. They always return one of the operands.<\/p>\n<p><strong>OR Operator ( | | ) &#8211;<\/strong> If the first value is true, the first value is returned. Otherwise, the second value is always returned.<\/p>\n<p><strong>AND Operator ( &amp;&amp; ) &#8211;<\/strong> If both values \u200b\u200bare true, the second value is always returned. If the first value is false then the first value is returned or if the second value is false then the second value is returned.<br \/>\nExample:<\/p>\n<pre><code class=\"language-javascript hljs\"><span class=\"hljs-keyword\">var<\/span> x = <span class=\"hljs-number\">220<\/span>;\r\n<span class=\"hljs-keyword\">var<\/span> y = <span class=\"hljs-string\">\"Hello\"<\/span>;\r\n<span class=\"hljs-keyword\">var<\/span> z = <span class=\"hljs-literal\">undefined<\/span>;\r\n        \r\nx | | y    <span class=\"hljs-comment\">\/\/ Returns 220 since the first value is truthy<\/span>\r\n        \r\nx | | z   <span class=\"hljs-comment\">\/\/ Returns 220 since the first value is truthy<\/span>\r\n        \r\nx &amp;&amp; y    <span class=\"hljs-comment\">\/\/ Returns \"Hello\" since both the values are truthy<\/span>\r\n        \r\ny &amp;&amp; z   <span class=\"hljs-comment\">\/\/ Returns undefined since the second value is falsy<\/span>\r\n        \r\n<span class=\"hljs-keyword\">if<\/span>( x &amp;&amp; y ){ \r\n  <span class=\"hljs-built_in\">console<\/span>.log(<span class=\"hljs-string\">\"Code runs\"<\/span> ); <span class=\"hljs-comment\">\/\/ This block runs because x &amp;&amp; y returns \"Hello\" (Truthy)<\/span>\r\n}   \r\n        \r\n<span class=\"hljs-keyword\">if<\/span>( x || z ){\r\n  <span class=\"hljs-built_in\">console<\/span>.log(<span class=\"hljs-string\">\"Code runs\"<\/span>);  <span class=\"hljs-comment\">\/\/ This block runs because x || y returns 220(Truthy)<\/span>\r\n}<\/code><\/pre>\n<ul>\n<li><strong>Equality Coercion<\/strong><\/li>\n<\/ul>\n<p>Enforcing equality takes place when using the &#8216;==&#8217; operator.<\/p>\n<p>As we said The &#8216; == &#8216; operator compares values, not types.<\/p>\n<p>Although the above statement is a simple way to explain the == operator, it is not entirely correct.<\/p>\n<p>In fact, when using the &#8216;==&#8217; operator, coercion takes place.<\/p>\n<p>The &#8216;==&#8217; operator converts two operands to the same type and then compares them.<\/p>\n<p>Example:<\/p>\n<pre><code class=\"language-javascript hljs\"><span class=\"hljs-keyword\">var<\/span> a = <span class=\"hljs-number\">12<\/span>;\r\n<span class=\"hljs-keyword\">var<\/span> b = <span class=\"hljs-string\">\"12\"<\/span>;\r\na == b <span class=\"hljs-comment\">\/\/ Returns true because both 'a' and 'b' are converted to the same type and then compared. Hence the operands are equal.<\/span><\/code><\/pre>\n<p>Coercion does not take place when using the \u2018===\u2019 operator. Both operands are not converted to the same type in the case of \u2018===\u2019 operator.<\/p>\n<p>Example:<\/p>\n<pre><code class=\"language-javascript hljs\"><span class=\"hljs-keyword\">var<\/span> a = <span class=\"hljs-number\">226<\/span>;\r\n<span class=\"hljs-keyword\">var<\/span> b = <span class=\"hljs-string\">\"226\"<\/span>;\r\n\r\na === b <span class=\"hljs-comment\">\/\/ Returns false because coercion does not take place and the  operands are of different types. Hence they are not equal.\u00a0<\/span><\/code><\/pre>\n<\/article>\n<\/section>\n<section id=\"is-javascript-a-statically-typed-or-a-dynamically-typed-language\" class=\"ibpage-article-header\">\n<h3><strong>7. Is javascript a statically typed or a dynamically typed language?<\/strong><\/h3>\n<article class=\"ibpage-article\">JavaScript is a dynamically typed language. In a dynamically typed language, the type of a variable is checked during\u00a0<strong>run-time\u00a0<\/strong>in contrast to a statically typed language, where the type of a variable is checked during\u00a0<strong>compile-time.<\/strong>Since javascript is a loosely(dynamically) typed language, variables in JS are not associated with any type. A variable can hold the value of any data type.For example, a variable that is assigned a number type can be converted to a string type:<\/p>\n<pre><code class=\"language-javascript hljs\"><span class=\"hljs-keyword\">var<\/span> a = <span class=\"hljs-number\">23<\/span>;\r\n<span class=\"hljs-keyword\">var<\/span> a = <span class=\"hljs-string\">\"Hello World!\"<\/span>;<\/code><\/pre>\n<\/article>\n<\/section>\n<div class=\"ib-articles-asset tracks\">\n<div class=\"ib-articles-asset__content\" data-class=\"ib-articles-asset-content-tracks\">\u00a0<strong style=\"color: #212121;font-size: 1.563em\">8. What is NaN property in JavaScript?<\/strong><\/div>\n<\/div>\n<section id=\"nan-property\" class=\"ibpage-article-header\">\n<article class=\"ibpage-article\">NaN property represents the\u00a0<strong>\u201cNot-a-Number\u201d\u00a0<\/strong>value. It indicates a value that is not a legal number.<strong>typeof\u00a0<\/strong>of NaN will return a\u00a0<strong>Number<\/strong>.To check if a value is NaN, we use the\u00a0<strong>isNaN()\u00a0<\/strong>function,<\/p>\n<pre><code class=\"language-javascript hljs\"><span class=\"hljs-built_in\">isNaN<\/span>(<span class=\"hljs-string\">\"Hello\"<\/span>)  <span class=\"hljs-comment\">\/\/ Returns true<\/span>\r\n<span class=\"hljs-built_in\">isNaN<\/span>(<span class=\"hljs-number\">345<\/span>)   <span class=\"hljs-comment\">\/\/ Returns false<\/span>\r\n<span class=\"hljs-built_in\">isNaN<\/span>(<span class=\"hljs-string\">'1'<\/span>)  <span class=\"hljs-comment\">\/\/ Returns false, since '1' is converted to Number type which results in 0 ( a number) <\/span>\r\n<span class=\"hljs-built_in\">isNaN<\/span>(<span class=\"hljs-literal\">true<\/span>) <span class=\"hljs-comment\">\/\/ Returns false, since true converted to Number type results in 1 ( a number)<\/span>\r\n<span class=\"hljs-built_in\">isNaN<\/span>(<span class=\"hljs-literal\">false<\/span>) <span class=\"hljs-comment\">\/\/ Returns false<\/span>\r\n<span class=\"hljs-built_in\">isNaN<\/span>(<span class=\"hljs-literal\">undefined<\/span>) <span class=\"hljs-comment\">\/\/ Returns true<\/span><\/code><\/pre>\n<\/article>\n<\/section>\n<section id=\"explain-passed-by-value-and-passed-by-reference\" class=\"ibpage-article-header\">\n<h3><strong>9. Explain passed by value and passed by reference.<\/strong><\/h3>\n<article class=\"ibpage-article\"><strong>In JavaScript, primitive data types are passed by value and non-primitive data types are passed by reference.<\/strong>For understanding passed by value and passed by reference, we need to understand what happens when we create a variable and assign a value to it,<\/p>\n<pre><code class=\"language-javascript hljs\"><span class=\"hljs-keyword\">var<\/span> x = <span class=\"hljs-number\">2<\/span>;<\/code><\/pre>\n<p>In the above example, we have created a variable x and assigned it the value \u201c2\u201d. Behind the scenes, the \u201c=&#8221; (assignment operator) allocates space in memory, stores the value \u201c2\u201d and returns the location of the allocated memory space. Hence, the variable x in the above code points to the memory space location instead of pointing directly to the value 2.<\/p>\n<p>Assign operator behaves differently when dealing with primitive and non-primitive data types,<\/p>\n<p><strong>Assign operator dealing with primitive types:<\/strong><\/p>\n<pre><code class=\"language-javascript hljs\"><span class=\"hljs-keyword\">var<\/span> y = <span class=\"hljs-number\">234<\/span>;\r\n<span class=\"hljs-keyword\">var<\/span> z = y;<\/code><\/pre>\n<p>In the example above, the assignment operator knows that the value assigned to y is a primitive type (numeric type in this case), so when the second line of code runs, where the value of y is assigned to z, the operator The assignment operator takes the value of y (234) and allocates a new space in memory and returns the address. Therefore, variable z does not point to the location of variable y but points to a new location in memory.<\/p>\n<pre><code class=\"language-javascript hljs\"><span class=\"hljs-keyword\">var<\/span> y = #<span class=\"hljs-number\">8454<\/span>; <span class=\"hljs-comment\">\/\/ y pointing to address of the value 234<\/span>\r\n\r\n<span class=\"hljs-keyword\">var<\/span> z = y; \r\n     \r\n<span class=\"hljs-keyword\">var<\/span> z = #<span class=\"hljs-number\">5411<\/span>; <span class=\"hljs-comment\">\/\/ z pointing to a completely new address of the value 234<\/span>\r\n     \r\n<span class=\"hljs-comment\">\/\/ Changing the value of y<\/span>\r\ny = <span class=\"hljs-number\">23<\/span>;\r\n<span class=\"hljs-built_in\">console<\/span>.log(z);  <span class=\"hljs-comment\">\/\/ Returns 234, since z points to a new address in the memory so changes in y will not effect z<\/span><\/code><\/pre>\n<p>From the above example, we can see that primitive data types when passed to another variable, are passed by value. Instead of just assigning the same address to another variable, the value is passed and new space of memory is created.<\/p>\n<p><strong>Assign operator dealing with non-primitive types:<\/strong><\/p>\n<pre><code class=\"language-javascript hljs\"><span class=\"hljs-keyword\">var<\/span> obj = { <span class=\"hljs-attr\">name<\/span>: <span class=\"hljs-string\">\"Vivek\"<\/span>, <span class=\"hljs-attr\">surname<\/span>: <span class=\"hljs-string\">\"Bisht\"<\/span> };\r\n<span class=\"hljs-keyword\">var<\/span> obj2 = obj;<\/code><\/pre>\n<p>In the above example, the assign operator directly passes the location of the variable obj to the variable obj2. In other words, the reference of the variable obj is passed to the variable obj2.<\/p>\n<pre><code class=\"language-javascript hljs\"><span class=\"hljs-keyword\">var<\/span> obj = #<span class=\"hljs-number\">8711<\/span>;  <span class=\"hljs-comment\">\/\/ obj pointing to address of { name: \"Vivek\", surname: \"Bisht\" }<\/span>\r\n<span class=\"hljs-keyword\">var<\/span> obj2 = obj;\r\n    \r\n<span class=\"hljs-keyword\">var<\/span> obj2 = #<span class=\"hljs-number\">8711<\/span>; <span class=\"hljs-comment\">\/\/ obj2 pointing to the same address <\/span>\r\n\r\n<span class=\"hljs-comment\">\/\/ changing the value of obj1<\/span>\r\n        \r\nobj.name = <span class=\"hljs-string\">\"Akki\"<\/span>;\r\n<span class=\"hljs-built_in\">console<\/span>.log(obj2);\r\n        \r\n<span class=\"hljs-comment\">\/\/ Returns {name:\"Akki\", surname:\"Bisht\"} since both the variables are pointing to the same address.<\/span><\/code><\/pre>\n<p>From the above example, we can see that while passing non-primitive data types, the assigned operator directly passes the address (reference).<\/p>\n<p>Therefore, non-primitive data types are always\u00a0<strong>passed by reference.<\/strong><\/p>\n<\/article>\n<\/section>\n<section id=\"immediately-invoked-function\" class=\"ibpage-article-header\">\n<h3><strong>9. What is an Immediately Invoked Function in JavaScript?<\/strong><\/h3>\n<article class=\"ibpage-article\"><strong>An Immediately Invoked Function ( known as IIFE and pronounced as IIFY) is a function that runs as soon as it is defined.<\/strong>Syntax of IIFE :<\/p>\n<pre><code class=\"language-javascript hljs\">(<span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span>()<\/span>{ \r\n  <span class=\"hljs-comment\">\/\/ Do something;<\/span>\r\n})();<\/code><\/pre>\n<p>To understand IIFE, we need to understand the two sets of parentheses that are added while creating an IIFE :<\/p>\n<p>The first set of parenthesis:<\/p>\n<pre><code class=\"language-javascript hljs\">(<span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> ()<\/span>{\r\n   <span class=\"hljs-comment\">\/\/Do something;<\/span>\r\n})<\/code><\/pre>\n<p>When running javascript code, whenever the compiler sees the word &#8220;function&#8221;, it assumes that we are declaring a function in the code. Therefore, if we do not use the first set of parentheses, the compiler will throw an error because it thinks that we are declaring a function and according to the function declaration syntax, the function should always have a name.<\/p>\n<pre><code class=\"language-javascript hljs\"><span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span>() <\/span>{\r\n  <span class=\"hljs-comment\">\/\/Do something;<\/span>\r\n}\r\n<span class=\"hljs-comment\">\/\/ Compiler gives an error since the syntax of declaring a function is wrong in the code above.<\/span><\/code><\/pre>\n<p>To remove this error, we add the first set of parenthesis that tells the compiler that the function is not a function declaration, instead, it\u2019s a function expression.<\/p>\n<p>The second set of parenthesis:<\/p>\n<pre><code class=\"language-javascript hljs\">(<span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> ()<\/span>{\r\n  <span class=\"hljs-comment\">\/\/Do something;<\/span>\r\n})();<\/code><\/pre>\n<p>From the definition of an IIFE, we know that our code should run as soon as it is defined. A function runs only when it is invoked. If we do not invoke the function, the function declaration is returned:<\/p>\n<pre><code class=\"language-javascript hljs\">(<span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> ()<\/span>{\r\n  <span class=\"hljs-comment\">\/\/ Do something;<\/span>\r\n})\r\n\r\n<span class=\"hljs-comment\">\/\/ Returns the function declaration<\/span><\/code><\/pre>\n<p><strong>Therefore to invoke the function, we use the second set of parenthesis.<\/strong><\/p>\n<\/article>\n<\/section>\n<section id=\"script-mode-and-its-characteristics\" class=\"ibpage-article-header\">\n<h3><strong>10. What do you mean by strict mode in javascript and characteristics of javascript strict-mode?<\/strong><\/h3>\n<article class=\"ibpage-article\">ECMAScript 5 now includes JavaScript Strict Mode, which allows you to write code or perform functions in a specific operating environment. In most cases, this language is &#8220;not particularly harsh&#8221; when it comes to throwing errors. However, in &#8220;strict mode&#8221;, all types of errors, including silent errors, will be generated. As a result, debugging becomes much simpler. Therefore, the possibility of programmers making mistakes is reduced.<strong>Characteristics of strict mode in javascript<\/strong><\/p>\n<ul>\n<li>Developers do not allow duplicate arguments.<\/li>\n<li>In strict mode, you will not be able to use JavaScript keywords as parameters or function names.<\/li>\n<li>The &#8216;use strict&#8217; keyword is used to set strict mode at the start of a script.<\/li>\n<li>Strict mode is supported by all browsers.<\/li>\n<li>Engineers will not be allowed to create global variables in &#8220;strict mode&#8221;.<\/li>\n<\/ul>\n<\/article>\n<\/section>\n<section id=\"explain-higher-order-functions-in-javascript\" class=\"ibpage-article-header\">\n<h3><strong>11. Explain Higher Order Functions in javascript.<\/strong><\/h3>\n<article class=\"ibpage-article\"><strong>Functions that operate on other functions, either by taking them as arguments or by returning them, are called higher-order functions.<\/strong>Higher-order functions are a result of functions being\u00a0<strong>first-class citizens\u00a0<\/strong>in javascript.Examples of higher-order functions:<\/p>\n<pre><code class=\"language-javascript hljs\"><span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">higherOrder<\/span>(<span class=\"hljs-params\">fn<\/span>) <\/span>{\r\n  fn();\r\n}\r\n   \r\nhigherOrder(<span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span>() <\/span>{ <span class=\"hljs-built_in\">console<\/span>.log(<span class=\"hljs-string\">\"Hello world\"<\/span>) }); \u00a0<\/code><\/pre>\n<pre><code class=\"language-javascript hljs\"><span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">higherOrder2<\/span>() <\/span>{\r\n  <span class=\"hljs-keyword\">return<\/span> <span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span>() <\/span>{\r\n    <span class=\"hljs-keyword\">return<\/span> <span class=\"hljs-string\">\"Do something\"<\/span>;\r\n  }\r\n}      \r\n<span class=\"hljs-keyword\">var<\/span> x = higherOrder2();\r\nx()   <span class=\"hljs-comment\">\/\/ Returns \"Do something\"<\/span><\/code><\/pre>\n<h3><strong>12. What is the difference between exec () and test () methods in javascript?<\/strong><\/h3>\n<h3><strong style=\"color: #333333;font-size: 15px\">test ()<\/strong><span style=\"color: #333333;font-size: 15px\">\u00a0and\u00a0<\/span><strong style=\"color: #333333;font-size: 15px\">exec ()<\/strong><span style=\"color: #333333;font-size: 15px\">\u00a0are RegExp expression methods used in javascript.\u00a0<\/span><\/h3>\n<article class=\"ibpage-article\">\n<ul>\n<li>We will use exec () to search a string for a specific pattern and if it finds it, it returns the pattern directly; otherwise it will return &#8220;empty&#8221; result.<\/li>\n<li>We will use test() to find the string for a particular pattern. It will return the boolean value \u201ctrue\u201d when finding the given text, otherwise it will return \u201cfalse\u201d.<\/li>\n<\/ul>\n<p><strong style=\"color: #212121;font-size: 1.563em\">13. What are some advantages of using External JavaScript?<\/strong><\/p>\n<article class=\"ibpage-article\">External JavaScript is JavaScript code (script) written in a separate file with the .js extension, which we then link inside the element or HTML file where the code is located.<\/article>\n<article class=\"ibpage-article\">Some advantages of external javascript are<\/article>\n<ul>\n<li class=\"ibpage-article\">It allows web designers and developers to collaborate on HTML and javascript files.<\/li>\n<li class=\"ibpage-article\">We can reuse code.<\/li>\n<li class=\"ibpage-article\">Very simple code readability in external javascript.<\/li>\n<\/ul>\n<h3 class=\"ibpage-article\"><strong>14. Mention some advantages of javascript.<\/strong><\/h3>\n<article class=\"ibpage-article\">Javascript has many advantages. Some of them are .<\/article>\n<ul>\n<li class=\"ibpage-article\">Javascript is also executed on the client side as well as the server side. There are many user interface frameworks that you can research and use. However, if you want to use JavaScript in the backend, you will need to learn NodeJS. It is currently the only JavaScript framework that can be used in the backend.<\/li>\n<li class=\"ibpage-article\">Javascript is an easy language to learn.<\/li>\n<li class=\"ibpage-article\">Websites are now more functional thanks to Javascript.<\/li>\n<li class=\"ibpage-article\">For the end user, Javascript is fast enough<\/li>\n<\/ul>\n<article class=\"ibpage-article\">\n<article class=\"ibpage-article\">\n<h2><span class=\"ez-toc-section\" id=\"JavaScript_Interview_Questions_for_Experienced\"><\/span><strong>JavaScript Interview Questions for Experienced<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<section id=\"arrow-functions\" class=\"ibpage-article-header\">\n<h3><strong>1. What are arrow functions?<\/strong><\/h3>\n<article class=\"ibpage-article\">The ES6 edition of the javascript language included Arrow functions as well. They give us a new and shorter syntax for declaring functions. Only a function expression can be used for arrow functions.Let\u2019s compare the normal function declaration and the arrow function declaration in detail:<\/p>\n<pre><code class=\"language-javascript hljs\"><span class=\"hljs-comment\">\/\/ Traditional Function Expression<\/span>\r\n<span class=\"hljs-keyword\">var<\/span> add = <span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span>(<span class=\"hljs-params\">a,b<\/span>)<\/span>{\r\n  <span class=\"hljs-keyword\">return<\/span> a + b;\r\n}\r\n\r\n<span class=\"hljs-comment\">\/\/ Arrow Function Expression<\/span>\r\n<span class=\"hljs-keyword\">var<\/span> arrowAdd = <span class=\"hljs-function\">(<span class=\"hljs-params\">a,b<\/span>) =&gt;<\/span> a + b;<\/code><\/pre>\n<p>Arrow functions are declared without the function keyword. If there is only one return expression, we do not need to use the return keyword in the arrow function, as in the example above. Additionally, for functions with only one line of code, curly braces { } can be omitted.<\/p>\n<pre><code class=\"language-javascript hljs\"><span class=\"hljs-comment\">\/\/ Traditional function expression<\/span>\r\n<span class=\"hljs-keyword\">var<\/span> multiplyBy2 = <span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span>(<span class=\"hljs-params\">num<\/span>)<\/span>{\r\n  <span class=\"hljs-keyword\">return<\/span> num * <span class=\"hljs-number\">2<\/span>;\r\n}\r\n<span class=\"hljs-comment\">\/\/ Arrow function expression<\/span>\r\n<span class=\"hljs-keyword\">var<\/span> arrowMultiplyBy2 = <span class=\"hljs-function\"><span class=\"hljs-params\">num<\/span> =&gt;<\/span> num * <span class=\"hljs-number\">2<\/span>;<\/code><\/pre>\n<p>If the function takes in only one argument, then the parenthesis () around the parameter can be omitted as shown in the code above.<\/p>\n<pre><code class=\"language-javascript hljs\"><span class=\"hljs-keyword\">var<\/span> obj1 = {\r\n  <span class=\"hljs-attr\">valueOfThis<\/span>: <span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span>()<\/span>{\r\n    <span class=\"hljs-keyword\">return<\/span> <span class=\"hljs-built_in\">this<\/span>;\r\n  }\r\n}\r\n<span class=\"hljs-keyword\">var<\/span> obj2 = {\r\n  <span class=\"hljs-attr\">valueOfThis<\/span>: <span class=\"hljs-function\">()=&gt;<\/span>{\r\n    <span class=\"hljs-keyword\">return<\/span> <span class=\"hljs-built_in\">this<\/span>;\r\n  }\r\n}\r\n\r\nobj1.valueOfThis(); <span class=\"hljs-comment\">\/\/ Will return the object obj1<\/span>\r\nobj2.valueOfThis(); <span class=\"hljs-comment\">\/\/ Will return window\/global object<\/span><\/code><\/pre>\n<\/article>\n<\/section>\n<section id=\"differences-between-declaring-variables-using-var-let-and-const\" class=\"ibpage-article-header\">\n<article class=\"ibpage-article\">The biggest difference between traditional function expressions and arrow functions is how this keyword is handled. By general definition, this keyword always refers to the object calling the function.As you can see in the above code, <strong>obj1.valueOfThis()<\/strong> returns obj1 because this keyword refers to the object calling the function.In arrow functions, there is no binding to this keyword. Objects that are used to call the keyword in an arrow function are not included in this.<\/p>\n<p>Rather, it inherits its value from the parent scope, which is the window object in this case. Therefore, in the above code, <strong>obj2.valueOfThis()<\/strong> returns the window object.<\/p>\n<h3><strong>2. What does prototype design model mean?<\/strong><\/h3>\n<p>The prototype model creates different objects, but instead of returning uninitialized objects, it creates objects whose values \u200b\u200bare copied from a model \u2013 or template \u2013 object. Also known as the Attribute model, the Prototype model is used to create prototypes.<\/p>\n<p>Introducing business objects with parameters that match database defaults is a good example of the usefulness of the Prototype pattern.<\/p>\n<p>The default settings of the newly created business object will be stored in the prototype object. The Prototype Model is rarely used in traditional languages, however, it is used to develop new objects and models in JavaScript, a prototype language.<\/p>\n<h3><strong>3. Difference between declaring variables with var, let and const.<\/strong><\/h3>\n<p>Before the ES6 version of javascript, only the var keyword was used to declare variables. With the ES6 release, let and const keywords were introduced to declare variables.<\/p>\n<p>&nbsp;<\/p>\n<figure class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>keyword<\/td>\n<td>const<\/td>\n<td>let<\/td>\n<td>var<\/td>\n<\/tr>\n<tr>\n<td>global scope<\/td>\n<td>no<\/td>\n<td>no<\/td>\n<td>yes<\/td>\n<\/tr>\n<tr>\n<td>function scope<\/td>\n<td>yes<\/td>\n<td>yes<\/td>\n<td>yes<\/td>\n<\/tr>\n<tr>\n<td>block scope<\/td>\n<td>yes<\/td>\n<td>yes<\/td>\n<td>no<\/td>\n<\/tr>\n<tr>\n<td>can be reassigned<\/td>\n<td>no<\/td>\n<td>yes<\/td>\n<td>yes<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<p><strong>Let\u2019s understand the differences with examples:<\/strong><\/p>\n<pre><code class=\"language-javascript hljs\"><span class=\"hljs-keyword\">var<\/span> variable1 = <span class=\"hljs-number\">23<\/span>;\r\n\r\n<span class=\"hljs-keyword\">let<\/span> variable2 = <span class=\"hljs-number\">89<\/span>;\r\n\r\n<span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">catchValues<\/span>()<\/span>{\r\n  <span class=\"hljs-built_in\">console<\/span>.log(variable1);\r\n  <span class=\"hljs-built_in\">console<\/span>.log(variable2);\r\n\r\n<span class=\"hljs-comment\">\/\/ Both the variables can be accessed anywhere since they are declared in the global scope<\/span>\r\n}\r\n\r\n<span class=\"hljs-built_in\">window<\/span>.variable1; <span class=\"hljs-comment\">\/\/ Returns the value 23<\/span>\r\n\r\n<span class=\"hljs-built_in\">window<\/span>.variable2; <span class=\"hljs-comment\">\/\/ Returns undefined<\/span><\/code><\/pre>\n<ul>\n<li>Variables declared with the let keyword in the global scope behave exactly like variables declared with the var keyword in the global scope. Any variable declared in the global scope with the var keyword and the let keyword are accessible from any position in code. But there is a difference!<\/li>\n<li>Variables declared with the var keyword in the global scope will be added to the window\/global object. Therefore, they are accessed using window.variableName.<\/li>\n<li>Although variables declared with the let keyword are not added to the global object, trying to access these variables using window.variableName will result in an error.<\/li>\n<\/ul>\n<p><strong>var vs let in functional scope<\/strong><\/p>\n<pre><code class=\"language-javascript hljs\"><span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">varVsLetFunction<\/span>()<\/span>{\r\n  <span class=\"hljs-keyword\">let<\/span> awesomeCar1 = <span class=\"hljs-string\">\"Audi\"<\/span>;\r\n  <span class=\"hljs-keyword\">var<\/span> awesomeCar2 = <span class=\"hljs-string\">\"Mercedes\"<\/span>;\r\n}\r\n\r\n<span class=\"hljs-built_in\">console<\/span>.log(awesomeCar1); <span class=\"hljs-comment\">\/\/ Throws an error<\/span>\r\n<span class=\"hljs-built_in\">console<\/span>.log(awesomeCar2); <span class=\"hljs-comment\">\/\/ Throws an error<\/span><\/code><\/pre>\n<p>Variables are declared in a functional\/local scope using\u00a0<strong>var\u00a0<\/strong>and\u00a0<strong>let\u00a0<\/strong>keywords behave exactly the same, meaning, they cannot be accessed from outside of the scope.<\/p>\n<pre><code class=\"language-javascript hljs\">{\r\n  <span class=\"hljs-keyword\">var<\/span> variable3 = [<span class=\"hljs-number\">1<\/span>, <span class=\"hljs-number\">2<\/span>, <span class=\"hljs-number\">3<\/span>, <span class=\"hljs-number\">4<\/span>];\r\n}\r\n\r\n<span class=\"hljs-built_in\">console<\/span>.log(variable3); <span class=\"hljs-comment\">\/\/ Outputs [1,2,3,4]<\/span>\r\n\r\n{\r\n  <span class=\"hljs-keyword\">let<\/span> variable4 = [<span class=\"hljs-number\">6<\/span>, <span class=\"hljs-number\">55<\/span>, -<span class=\"hljs-number\">1<\/span>, <span class=\"hljs-number\">2<\/span>];\r\n}\r\n\r\n<span class=\"hljs-built_in\">console<\/span>.log(variable4); <span class=\"hljs-comment\">\/\/ Throws error<\/span>\r\n\r\n<span class=\"hljs-keyword\">for<\/span>(<span class=\"hljs-keyword\">let<\/span> i = <span class=\"hljs-number\">0<\/span>; i &lt; <span class=\"hljs-number\">2<\/span>; i++){\r\n  <span class=\"hljs-comment\">\/\/Do something<\/span>\r\n}\r\n\r\n<span class=\"hljs-built_in\">console<\/span>.log(i); <span class=\"hljs-comment\">\/\/ Throws error<\/span>\r\n\r\n<span class=\"hljs-keyword\">for<\/span>(<span class=\"hljs-keyword\">var<\/span> j = <span class=\"hljs-number\">0<\/span>; j &lt; <span class=\"hljs-number\">2<\/span>; i++){\r\n  <span class=\"hljs-comment\">\/\/ Do something<\/span>\r\n}\r\n\r\n<span class=\"hljs-built_in\">console<\/span>.log(j) <span class=\"hljs-comment\">\/\/ Outputs 2 <\/span><\/code><\/pre>\n<ul>\n<li>In javascript, a block refers to code written between curly braces {}.<\/li>\n<li>Variables declared with the var keyword are not block scoped.<\/li>\n<li>This means that a variable declared in block scope {} with the var keyword is equivalent to declaring the variable in the global scope.<\/li>\n<li>Variables declared with the let keyword inside a block scope cannot be accessed from outside the block.<\/li>\n<\/ul>\n<p>Const keyword<\/p>\n<ul>\n<li>Variables with const keyword behave exactly like a variable declared with let keyword with only one difference, any variable declared with const keyword cannot be assigned again.<\/li>\n<li>Example:<\/li>\n<\/ul>\n<pre><code class=\"language-javascript hljs\"><span class=\"hljs-keyword\">const<\/span> x = {<span class=\"hljs-attr\">name<\/span>:<span class=\"hljs-string\">\"Vivek\"<\/span>};\r\n\r\nx = {<span class=\"hljs-attr\">address<\/span>: <span class=\"hljs-string\">\"India\"<\/span>}; <span class=\"hljs-comment\">\/\/ Throws an error<\/span>\r\n\r\nx.name = <span class=\"hljs-string\">\"Nikhil\"<\/span>; <span class=\"hljs-comment\">\/\/ No error is thrown<\/span>\r\n\r\n<span class=\"hljs-keyword\">const<\/span> y = <span class=\"hljs-number\">23<\/span>;\r\n\r\ny = <span class=\"hljs-number\">44<\/span>; <span class=\"hljs-comment\">\/\/ Throws an error<\/span><\/code><\/pre>\n<\/article>\n<\/section>\n<section id=\"rest-parameter-and-spread-operator\" class=\"ibpage-article-header\">\n<article class=\"ibpage-article\">In the above code, although we can change the value of a property inside a variable declared with the const keyword, we cannot completely reassign the variable itself.<\/p>\n<h3><strong>4. What are the remaining parameters and the propagation operator?<\/strong><\/h3>\n<p>Rest parameter and spread operator were introduced in ES6 version of javascript.<\/p>\n<p>Remaining parameters (\u2026):<\/p>\n<ul>\n<li>It provides an improved way to handle function parameters.<\/li>\n<li>By using the rest parameter syntax, we can create functions that can take a variable number of arguments.<\/li>\n<li>Any number of arguments will be converted to an array using the remaining parameter.<\/li>\n<li>This also helps extract all or part of the argument.<\/li>\n<li>The remaining parameter can be used by applying three dots (&#8230;) before the parameter.<\/li>\n<\/ul>\n<pre><code class=\"language-javascript hljs\"><span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">extractingArgs<\/span>(<span class=\"hljs-params\">...args<\/span>)<\/span>{\r\n  <span class=\"hljs-keyword\">return<\/span> args[<span class=\"hljs-number\">1<\/span>];\r\n}\r\n\r\n<span class=\"hljs-comment\">\/\/ extractingArgs(8,9,1); \/\/ Returns 9<\/span>\r\n\r\n<span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">addAllArgs<\/span>(<span class=\"hljs-params\">...args<\/span>)<\/span>{\r\n  <span class=\"hljs-keyword\">let<\/span> sumOfArgs = <span class=\"hljs-number\">0<\/span>;\r\n  <span class=\"hljs-keyword\">let<\/span> i = <span class=\"hljs-number\">0<\/span>;\r\n  <span class=\"hljs-keyword\">while<\/span>(i &lt; args.length){\r\n    sumOfArgs += args[i];\r\n    i++;\r\n  }\r\n  <span class=\"hljs-keyword\">return<\/span> sumOfArgs;\r\n}\r\n\r\naddAllArgs(<span class=\"hljs-number\">6<\/span>, <span class=\"hljs-number\">5<\/span>, <span class=\"hljs-number\">7<\/span>, <span class=\"hljs-number\">99<\/span>); <span class=\"hljs-comment\">\/\/ Returns 117<\/span>\r\naddAllArgs(<span class=\"hljs-number\">1<\/span>, <span class=\"hljs-number\">3<\/span>, <span class=\"hljs-number\">4<\/span>); <span class=\"hljs-comment\">\/\/ Returns 8<\/span><\/code><\/pre>\n<p><strong>**Note- Rest parameter should always be used at the last parameter of a function:<\/strong><\/p>\n<pre><code class=\"language-javascript hljs\"><span class=\"hljs-comment\">\/\/ Incorrect way to use rest parameter<\/span>\r\n<span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">randomFunc<\/span>(<span class=\"hljs-params\">a,...args,c<\/span>)<\/span>{\r\n<span class=\"hljs-comment\">\/\/Do something<\/span>\r\n}\r\n\r\n<span class=\"hljs-comment\">\/\/ Correct way to use rest parameter<\/span>\r\n<span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">randomFunc2<\/span>(<span class=\"hljs-params\">a,b,...args<\/span>)<\/span>{\r\n<span class=\"hljs-comment\">\/\/Do something<\/span>\r\n}<\/code><\/pre>\n<ul>\n<li><strong>Spread operator (\u2026):\u00a0<\/strong>Although the syntax of the spread operator is exactly the same as the rest parameter, the spread operator is used to spreading an array, and object literals. We also use spread operators where one or more arguments are expected in a function call.<\/li>\n<\/ul>\n<pre><code class=\"language-javascript hljs\"><span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">addFourNumbers<\/span>(<span class=\"hljs-params\">num1,num2,num3,num4<\/span>)<\/span>{\r\n  <span class=\"hljs-keyword\">return<\/span> num1 + num2 + num3 + num4;\r\n}\r\n\r\n<span class=\"hljs-keyword\">let<\/span> fourNumbers = [<span class=\"hljs-number\">5<\/span>, <span class=\"hljs-number\">6<\/span>, <span class=\"hljs-number\">7<\/span>, <span class=\"hljs-number\">8<\/span>];\r\n\r\n\r\naddFourNumbers(...fourNumbers);\r\n<span class=\"hljs-comment\">\/\/ Spreads [5,6,7,8] as 5,6,7,8<\/span>\r\n\r\n<span class=\"hljs-keyword\">let<\/span> array1 = [<span class=\"hljs-number\">3<\/span>, <span class=\"hljs-number\">4<\/span>, <span class=\"hljs-number\">5<\/span>, <span class=\"hljs-number\">6<\/span>];\r\n<span class=\"hljs-keyword\">let<\/span> clonedArray1 = [...array1];\r\n<span class=\"hljs-comment\">\/\/ Spreads the array into 3,4,5,6<\/span>\r\n<span class=\"hljs-built_in\">console<\/span>.log(clonedArray1); <span class=\"hljs-comment\">\/\/ Outputs [3,4,5,6]<\/span>\r\n\r\n\r\n<span class=\"hljs-keyword\">let<\/span> obj1 = {<span class=\"hljs-attr\">x<\/span>:<span class=\"hljs-string\">'Hello'<\/span>, <span class=\"hljs-attr\">y<\/span>:<span class=\"hljs-string\">'Bye'<\/span>};\r\n<span class=\"hljs-keyword\">let<\/span> clonedObj1 = {...obj1}; <span class=\"hljs-comment\">\/\/ Spreads and clones obj1<\/span>\r\n<span class=\"hljs-built_in\">console<\/span>.log(obj1);\r\n\r\n<span class=\"hljs-keyword\">let<\/span> obj2 = {<span class=\"hljs-attr\">z<\/span>:<span class=\"hljs-string\">'Yes'<\/span>, <span class=\"hljs-attr\">a<\/span>:<span class=\"hljs-string\">'No'<\/span>};\r\n<span class=\"hljs-keyword\">let<\/span> mergedObj = {...obj1, ...obj2}; <span class=\"hljs-comment\">\/\/ Spreads both the objects and merges it<\/span>\r\n<span class=\"hljs-built_in\">console<\/span>.log(mergedObj);\r\n<span class=\"hljs-comment\">\/\/ Outputs {x:'Hello', y:'Bye',z:'Yes',a:'No'};<\/span><\/code><\/pre>\n<\/article>\n<\/section>\n<section id=\"different-methods-can-you-make-an-object\" class=\"ibpage-article-header\">\n<h3><strong>5. In JavaScript, how many different methods can you make an object?<\/strong><\/h3>\n<article class=\"ibpage-article\">In JavaScript, there are many ways to declare or construct an object.<\/p>\n<ol>\n<li>Object.<\/li>\n<li>using Class.<\/li>\n<li>create Method.<\/li>\n<li>Object Literals.<\/li>\n<li>using Function.<\/li>\n<li>Object Constructor.<\/li>\n<\/ol>\n<\/article>\n<\/section>\n<section id=\"use-of-promises\" class=\"ibpage-article-header\">\n<h3><strong>6. What is the use of promises in javascript?<\/strong><\/h3>\n<p>Promises are employed in javascript to manage asynchronous operations.<\/p>\n<p>Before promises, callbacks are used to handle asynchronous operations. But because callback functionality is limited, using multiple callbacks to handle asynchronous code can lead to unmanageable code.<\/p>\n<p>The Promise object has four states &#8211;<\/p>\n<ol>\n<li>Pending &#8211; The initial state of the promise. This status means that the promise has not been kept or rejected, it is in a pending state.<\/li>\n<li>Completed &#8211; This status indicates that the promise has been fulfilled, meaning the asynchronous operation has completed.<\/li>\n<li>Rejected: This status indicates that the promise was rejected for some reason, meaning the asynchronous operation failed.<\/li>\n<li>Resolved &#8211; This status means the promise has been rejected or fulfilled. A promise created using the Promise constructor supports a callback function with two parameters: resolve and reject respectively.<\/li>\n<\/ol>\n<p style=\"text-align: center\"><strong><a class=\"in-cell-link\" href=\"https:\/\/entri.app\/course\/full-stack-developer-course\/\" target=\"_blank\" rel=\"noopener\">Experience the power of our full stack development course with a free demo \u2013 enroll now!<\/a><\/strong><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Tips_to_prepare_for_a_JavaScript_coding_interview\"><\/span><strong><span id=\"6\" class=\"scrollspy-section\">Tips to prepare for a JavaScript coding interview\u00a0<\/span><\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>There are 5 tips candidates should keep in mind when attending a JavaScript coding interview:<\/p>\n<ul>\n<li><strong> Master JavaScript basics:<\/strong> Candidates should have a solid understanding of the fundamentals of JavaScript, including variables, loops, conditions, objects, and data types. Additionally, practicing coding skills is also important.<\/li>\n<li><strong>Explore popular libraries and frameworks:<\/strong> Get familiar with the most popular JavaScript libraries and frameworks like Vue.js, React, and more. Helps understand key concepts.<\/li>\n<li><strong>Practice Java Coding on a Whiteboard:<\/strong> Java Coding skills can be perfected by practicing whiteboard coding. Candidates must solve coding problems and clearly explain their thought process. They should primarily focus on simplicity, clarity, and efficiency.<\/li>\n<li><strong>Test code:<\/strong> After writing Java solutions, test them with a variety of inputs and make sure they work correctly and can handle difficult cases. Consider the time complexity of solutions and aim for efficiency.<\/li>\n<li><strong>JavaScript Projects Review:<\/strong> It is essential to discuss JavaScript projects during the interview.<br \/>\nThe interviewee should clearly explain their approach and how they overcame the challenge.<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"Red_Flags\"><\/span><strong>Red Flags<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>There are a few red flags that hiring managers should look out for in a JavaScript coding interview:<\/p>\n<ul>\n<li>Lack of basic JavaScript knowledge<\/li>\n<li>Providing inefficient solutions<\/li>\n<li>Lack of practical problem-solving skills<\/li>\n<li>Limited knowledge of asynchronous programming<\/li>\n<li>Copying and pasting code<\/li>\n<li>Inability to articulate thought processes or provide a clear explanation of their approach to a proble<\/li>\n<li>Lack of knowledge of modern JavaScript<\/li>\n<li>Failure to handle errors and account for extreme cases<\/li>\n<\/ul>\n<p>Candidates are judged primarily on their understanding of basic JavaScript concepts and skills. By mastering the fundamentals and practicing, candidates can ace their interviews. In addition, it is important to strive to be clear, precise, and honest throughout the interview.<\/p>\n<\/section>\n<\/article>\n<p><code class=\"language-javascript hljs\" style=\"font-size: 12px\"><\/code><\/p>\n<\/article>\n<\/article>\n<\/article>\n<\/section>\n<\/article>\n<\/section>\n","protected":false},"excerpt":{"rendered":"<p>JavaScript, made by Brendan Eich in 1995, is one of the foremost broadly utilized web advancement dialects. It was planned to construct energetic web pages at first. A script could be a JS program which will be included to the HTML of any web page. When the page loads, these scripts execute consequently. A dialect [&hellip;]<\/p>\n","protected":false},"author":110,"featured_media":25586508,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[802,1926],"tags":[],"class_list":["post-25585977","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-articles","category-full-stack-web-development"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>JavaScript coding interview questions and Answers - Entri 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:\/\/entri.app\/blog\/javascript-coding-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 coding interview questions and Answers - Entri Blog\" \/>\n<meta property=\"og:description\" content=\"JavaScript, made by Brendan Eich in 1995, is one of the foremost broadly utilized web advancement dialects. It was planned to construct energetic web pages at first. A script could be a JS program which will be included to the HTML of any web page. When the page loads, these scripts execute consequently. A dialect [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/entri.app\/blog\/javascript-coding-interview-questions-and-answers\/\" \/>\n<meta property=\"og:site_name\" content=\"Entri Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/entri.me\/\" \/>\n<meta property=\"article:published_time\" content=\"2024-06-20T12:01:53+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-06-20T12:03:02+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2024\/06\/Coding_BlogBannerCoding_BlogBanner-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"820\" \/>\n\t<meta property=\"og:image:height\" content=\"615\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Juwairiya Mahin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@entri_app\" \/>\n<meta name=\"twitter:site\" content=\"@entri_app\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Juwairiya Mahin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"23 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/entri.app\/blog\/javascript-coding-interview-questions-and-answers\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/entri.app\/blog\/javascript-coding-interview-questions-and-answers\/\"},\"author\":{\"name\":\"Juwairiya Mahin\",\"@id\":\"https:\/\/entri.app\/blog\/#\/schema\/person\/da9e9899c834feb2c32a887101c5fbfc\"},\"headline\":\"JavaScript coding interview questions and Answers\",\"datePublished\":\"2024-06-20T12:01:53+00:00\",\"dateModified\":\"2024-06-20T12:03:02+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/entri.app\/blog\/javascript-coding-interview-questions-and-answers\/\"},\"wordCount\":3549,\"publisher\":{\"@id\":\"https:\/\/entri.app\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/entri.app\/blog\/javascript-coding-interview-questions-and-answers\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2024\/06\/Coding_BlogBannerCoding_BlogBanner-1.png\",\"articleSection\":[\"Articles\",\"Full Stack Web Development\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/entri.app\/blog\/javascript-coding-interview-questions-and-answers\/\",\"url\":\"https:\/\/entri.app\/blog\/javascript-coding-interview-questions-and-answers\/\",\"name\":\"JavaScript coding interview questions and Answers - Entri Blog\",\"isPartOf\":{\"@id\":\"https:\/\/entri.app\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/entri.app\/blog\/javascript-coding-interview-questions-and-answers\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/entri.app\/blog\/javascript-coding-interview-questions-and-answers\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2024\/06\/Coding_BlogBannerCoding_BlogBanner-1.png\",\"datePublished\":\"2024-06-20T12:01:53+00:00\",\"dateModified\":\"2024-06-20T12:03:02+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/entri.app\/blog\/javascript-coding-interview-questions-and-answers\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/entri.app\/blog\/javascript-coding-interview-questions-and-answers\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/entri.app\/blog\/javascript-coding-interview-questions-and-answers\/#primaryimage\",\"url\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2024\/06\/Coding_BlogBannerCoding_BlogBanner-1.png\",\"contentUrl\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2024\/06\/Coding_BlogBannerCoding_BlogBanner-1.png\",\"width\":820,\"height\":615,\"caption\":\"Coding_BlogBannerCoding_BlogBanner (1)\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/entri.app\/blog\/javascript-coding-interview-questions-and-answers\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/entri.app\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Full Stack Web Development\",\"item\":\"https:\/\/entri.app\/blog\/category\/full-stack-web-development\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"JavaScript coding interview questions and Answers\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/entri.app\/blog\/#website\",\"url\":\"https:\/\/entri.app\/blog\/\",\"name\":\"Entri Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/entri.app\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/entri.app\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/entri.app\/blog\/#organization\",\"name\":\"Entri App\",\"url\":\"https:\/\/entri.app\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/entri.app\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2019\/10\/Entri-Logo-1.png\",\"contentUrl\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2019\/10\/Entri-Logo-1.png\",\"width\":989,\"height\":446,\"caption\":\"Entri App\"},\"image\":{\"@id\":\"https:\/\/entri.app\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/entri.me\/\",\"https:\/\/x.com\/entri_app\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/entri.app\/blog\/#\/schema\/person\/da9e9899c834feb2c32a887101c5fbfc\",\"name\":\"Juwairiya Mahin\",\"url\":\"https:\/\/entri.app\/blog\/author\/juwairiyaentri\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"JavaScript coding interview questions and Answers - Entri 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:\/\/entri.app\/blog\/javascript-coding-interview-questions-and-answers\/","og_locale":"en_US","og_type":"article","og_title":"JavaScript coding interview questions and Answers - Entri Blog","og_description":"JavaScript, made by Brendan Eich in 1995, is one of the foremost broadly utilized web advancement dialects. It was planned to construct energetic web pages at first. A script could be a JS program which will be included to the HTML of any web page. When the page loads, these scripts execute consequently. A dialect [&hellip;]","og_url":"https:\/\/entri.app\/blog\/javascript-coding-interview-questions-and-answers\/","og_site_name":"Entri Blog","article_publisher":"https:\/\/www.facebook.com\/entri.me\/","article_published_time":"2024-06-20T12:01:53+00:00","article_modified_time":"2024-06-20T12:03:02+00:00","og_image":[{"width":820,"height":615,"url":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2024\/06\/Coding_BlogBannerCoding_BlogBanner-1.png","type":"image\/png"}],"author":"Juwairiya Mahin","twitter_card":"summary_large_image","twitter_creator":"@entri_app","twitter_site":"@entri_app","twitter_misc":{"Written by":"Juwairiya Mahin","Est. reading time":"23 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/entri.app\/blog\/javascript-coding-interview-questions-and-answers\/#article","isPartOf":{"@id":"https:\/\/entri.app\/blog\/javascript-coding-interview-questions-and-answers\/"},"author":{"name":"Juwairiya Mahin","@id":"https:\/\/entri.app\/blog\/#\/schema\/person\/da9e9899c834feb2c32a887101c5fbfc"},"headline":"JavaScript coding interview questions and Answers","datePublished":"2024-06-20T12:01:53+00:00","dateModified":"2024-06-20T12:03:02+00:00","mainEntityOfPage":{"@id":"https:\/\/entri.app\/blog\/javascript-coding-interview-questions-and-answers\/"},"wordCount":3549,"publisher":{"@id":"https:\/\/entri.app\/blog\/#organization"},"image":{"@id":"https:\/\/entri.app\/blog\/javascript-coding-interview-questions-and-answers\/#primaryimage"},"thumbnailUrl":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2024\/06\/Coding_BlogBannerCoding_BlogBanner-1.png","articleSection":["Articles","Full Stack Web Development"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/entri.app\/blog\/javascript-coding-interview-questions-and-answers\/","url":"https:\/\/entri.app\/blog\/javascript-coding-interview-questions-and-answers\/","name":"JavaScript coding interview questions and Answers - Entri Blog","isPartOf":{"@id":"https:\/\/entri.app\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/entri.app\/blog\/javascript-coding-interview-questions-and-answers\/#primaryimage"},"image":{"@id":"https:\/\/entri.app\/blog\/javascript-coding-interview-questions-and-answers\/#primaryimage"},"thumbnailUrl":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2024\/06\/Coding_BlogBannerCoding_BlogBanner-1.png","datePublished":"2024-06-20T12:01:53+00:00","dateModified":"2024-06-20T12:03:02+00:00","breadcrumb":{"@id":"https:\/\/entri.app\/blog\/javascript-coding-interview-questions-and-answers\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/entri.app\/blog\/javascript-coding-interview-questions-and-answers\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/entri.app\/blog\/javascript-coding-interview-questions-and-answers\/#primaryimage","url":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2024\/06\/Coding_BlogBannerCoding_BlogBanner-1.png","contentUrl":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2024\/06\/Coding_BlogBannerCoding_BlogBanner-1.png","width":820,"height":615,"caption":"Coding_BlogBannerCoding_BlogBanner (1)"},{"@type":"BreadcrumbList","@id":"https:\/\/entri.app\/blog\/javascript-coding-interview-questions-and-answers\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/entri.app\/blog\/"},{"@type":"ListItem","position":2,"name":"Full Stack Web Development","item":"https:\/\/entri.app\/blog\/category\/full-stack-web-development\/"},{"@type":"ListItem","position":3,"name":"JavaScript coding interview questions and Answers"}]},{"@type":"WebSite","@id":"https:\/\/entri.app\/blog\/#website","url":"https:\/\/entri.app\/blog\/","name":"Entri Blog","description":"","publisher":{"@id":"https:\/\/entri.app\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/entri.app\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/entri.app\/blog\/#organization","name":"Entri App","url":"https:\/\/entri.app\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/entri.app\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2019\/10\/Entri-Logo-1.png","contentUrl":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2019\/10\/Entri-Logo-1.png","width":989,"height":446,"caption":"Entri App"},"image":{"@id":"https:\/\/entri.app\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/entri.me\/","https:\/\/x.com\/entri_app"]},{"@type":"Person","@id":"https:\/\/entri.app\/blog\/#\/schema\/person\/da9e9899c834feb2c32a887101c5fbfc","name":"Juwairiya Mahin","url":"https:\/\/entri.app\/blog\/author\/juwairiyaentri\/"}]}},"_links":{"self":[{"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/posts\/25585977","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/users\/110"}],"replies":[{"embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/comments?post=25585977"}],"version-history":[{"count":5,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/posts\/25585977\/revisions"}],"predecessor-version":[{"id":25586511,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/posts\/25585977\/revisions\/25586511"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/media\/25586508"}],"wp:attachment":[{"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/media?parent=25585977"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/categories?post=25585977"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/tags?post=25585977"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}