{"id":73,"date":"2023-09-06T17:28:40","date_gmt":"2023-09-06T16:28:40","guid":{"rendered":"https:\/\/codeblog.xyz\/?p=73"},"modified":"2023-10-23T20:30:08","modified_gmt":"2023-10-23T17:30:08","slug":"50-intermediate-javascript-questions","status":"publish","type":"post","link":"https:\/\/codeblog.xyz\/?p=73","title":{"rendered":"50 intermediate javascript questions"},"content":{"rendered":"\n<p>Here are 50 intermediate-level JavaScript questions along with their answers and code examples:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>What is Hoisting in JavaScript?<\/strong> \n<ul class=\"wp-block-list\">\n<li>Hoisting is JavaScript&#8217;s behavior of moving declarations to the top of their containing scope. Note that only the declarations are hoisted, not the initializations.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text\/javascript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;JavaScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;js&quot;}\">   console.log(myVar); \/\/ undefined\n   var myVar = 5;\n   console.log(myVar); \/\/ 5<\/pre><\/div>\n\n\n\n<ol class=\"wp-block-list\" start=\"2\">\n<li><strong>What are JavaScript Prototypes?<\/strong> \n<ul class=\"wp-block-list\">\n<li>Prototypes are the mechanism by which JavaScript objects inherit features from one another. The prototype is a property on a constructor function that sets what will become the <code>__proto__<\/code> property on the constructed object.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text\/javascript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;JavaScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;js&quot;}\">   function Person(firstName, lastName) {\n     this.firstName = firstName;\n     this.lastName = lastName;\n   }\n\n   Person.prototype.fullName = function() {\n     return this.firstName + ' ' + this.lastName;\n   }\n\n   const person = new Person('John', 'Doe');\n   console.log(person.fullName()); \/\/ &quot;John Doe&quot;<\/pre><\/div>\n\n\n\n<ol class=\"wp-block-list\" start=\"3\">\n<li><strong>What is Event Bubbling in JavaScript?<\/strong> \n<ul class=\"wp-block-list\">\n<li>Event bubbling is a type of event propagation in the HTML DOM API, when an event occurs in an element inside another element, and both elements have registered a handle for that event. With bubbling, the event is first captured and handled by the innermost element and then propagated to outer elements.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text\/javascript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;JavaScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;js&quot;}\">   document.querySelector(&quot;#parent&quot;).addEventListener('click', (event) =&gt; {\n     alert(&quot;Parent Clicked!&quot;);\n   }, false);\n\n   document.querySelector(&quot;#child&quot;).addEventListener('click', (event) =&gt; {\n     alert(&quot;Child Clicked!&quot;);\n     event.stopPropagation();\n   }, false);<\/pre><\/div>\n\n\n\n<ol class=\"wp-block-list\" start=\"4\">\n<li><strong>What is Event Delegation in JavaScript?<\/strong> \n<ul class=\"wp-block-list\">\n<li>Event delegation is a technique involving adding event listeners to a parent element instead of adding them to the descendant elements. The listener will fire whenever the event is fired on the descendant elements due to event bubbling up the DOM.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text\/javascript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;JavaScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;js&quot;}\">   document.querySelector(&quot;#parent&quot;).addEventListener('click', function(event) {\n     if (event.target.matches(&quot;#child&quot;)) {\n       alert(&quot;Child Clicked!&quot;);\n     }\n   });<\/pre><\/div>\n\n\n\n<ol class=\"wp-block-list\" start=\"5\">\n<li><strong>What is a JavaScript Class?<\/strong> \n<ul class=\"wp-block-list\">\n<li>JavaScript Classes are a template for creating objects. They encapsulate data with code to manipulate that data. Classes in JS are built on prototypes but also have some syntax and semantics that are not shared with ES5 class-like semantics.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text\/javascript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;JavaScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;js&quot;}\">   class Rectangle {\n     constructor(height, width) {\n       this.height = height;\n       this.width = width;\n     }\n\n     area() {\n       return this.height * this.width;\n     }\n   }\n\n   const rectangle = new Rectangle(5, 8);\n   console.log(rectangle.area()); \/\/ 40<\/pre><\/div>\n\n\n\n<ol class=\"wp-block-list\" start=\"6\">\n<li><strong>What is a JavaScript Promise?<\/strong> \n<ul class=\"wp-block-list\">\n<li>A Promise in JavaScript represents a value which may not be available yet, but will be available in the future, or it will never be available.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text\/javascript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;JavaScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;js&quot;}\">   var promise = new Promise(function(resolve, reject) {\n     \/\/ a mock async action using setTimeout\n     setTimeout(function() {\n       resolve('Done!');\n     }, 1000);\n   });\n\n   promise.then(function(value) {\n     console.log(value);\n     \/\/ &quot;Done!&quot;\n   });<\/pre><\/div>\n\n\n\n<ol class=\"wp-block-list\" start=\"7\">\n<li><strong>What is &#8216;this&#8217; keyword in JavaScript?<\/strong> \n<ul class=\"wp-block-list\">\n<li>The JavaScript <code>this<\/code> keyword refers to the object it belongs to. It has different values depending on where it is used: In a method, <code>this<\/code> refers to the owner object and in a function, <code>this<\/code> refers to the global object.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text\/javascript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;JavaScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;js&quot;}\">   \/\/ In object method\n   var person = {\n     firstName: &quot;John&quot;,\n     lastName : &quot;Doe&quot;,\n     id     : 5566,\n     fullName : function() {\n       return this.firstName + &quot; &quot; + this.lastName;\n     }\n   };\n   console.log(person.fullName()); \/\/ John Doe\n\n   \/\/ In regular function\n   function myFunction() {\n     return this;\n   }\n   console.log(myFunction() === window); \/\/ true in a browser<\/pre><\/div>\n\n\n\n<ol class=\"wp-block-list\" start=\"8\">\n<li><strong>What is an Immediately Invoked Function Expression (IIFE)?<\/strong> \n<ul class=\"wp-block-list\">\n<li>An IIFE is a function in JavaScript that runs as soon as it is defined.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text\/javascript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;JavaScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;js&quot;}\">   (function () {\n     var name = 'Hello World';\n     console.log(name);\n   })(); \/\/ Hello World<\/pre><\/div>\n\n\n\n<ol class=\"wp-block-list\" start=\"9\">\n<li><strong>What are JavaScript data types?<\/strong> \n<ul class=\"wp-block-list\">\n<li>JavaScript data types include:<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Number<\/li>\n\n\n\n<li>String<\/li>\n\n\n\n<li>Boolean<\/li>\n\n\n\n<li>Object<\/li>\n\n\n\n<li>Undefined<\/li>\n\n\n\n<li>Null<\/li>\n\n\n\n<li>Symbol<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\" start=\"9\">\n<li><strong>What is a constructor function in JavaScript?<\/strong> \n<ul class=\"wp-block-list\">\n<li>A constructor function is a function that is used to instantiate new objects with properties and methods defined by that function.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text\/javascript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;JavaScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;js&quot;}\">   function Car(make, model, year) {\n     this.make = make;\n     this.model = model;\n     this.year = year;\n   }\n\n   var myCar = new Car('Toyota', 'Corolla', 2005);\n   console.log(myCar.model); \/\/ &quot;Corolla&quot;<\/pre><\/div>\n\n\n\n<ol class=\"wp-block-list\" start=\"11\">\n<li><strong>What are getter and setter methods in JavaScript?<\/strong> \n<ul class=\"wp-block-list\">\n<li>Getters and setters are functions or methods used to get and set the values of variables. The <code>get<\/code> and <code>set<\/code> syntax binds an object property to a function that will be called when that property is looked up or set.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text\/javascript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;JavaScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;js&quot;}\">   class Circle {\n     constructor(radius) {\n       this._radius = radius;\n     }\n\n     get radius()\n\n {\n       return this._radius;\n     }\n\n     set radius(radius) {\n       if (radius &gt; 0) {\n         this._radius = radius;\n       }\n     }\n   }\n\n   let circle = new Circle(5);\n   console.log(circle.radius); \/\/ 5\n   circle.radius = 10;\n   console.log(circle.radius); \/\/ 10<\/pre><\/div>\n\n\n\n<ol class=\"wp-block-list\" start=\"12\">\n<li><strong>What are Arrow Functions in JavaScript?<\/strong> \n<ul class=\"wp-block-list\">\n<li>Arrow functions were introduced with ES6 as a new syntax for writing JavaScript functions. They save developers time and simplify function scope.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text\/javascript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;JavaScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;js&quot;}\">   const greet = () =&gt; 'Hello, World!';\n   console.log(greet()); \/\/ &quot;Hello, World!&quot;<\/pre><\/div>\n\n\n\n<ol class=\"wp-block-list\" start=\"13\">\n<li><strong>What is a closure in JavaScript?<\/strong> \n<ul class=\"wp-block-list\">\n<li>A closure is the combination of a function and the lexical environment within which that function was declared. In other words, a closure gives you access to an outer function\u2019s scope from an inner function.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text\/javascript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;JavaScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;js&quot;}\">   function makeAdder(x) {\n     return function(y) {\n       return x + y;\n     };\n   }\n\n   var add5 = makeAdder(5);\n   console.log(add5(2));  \/\/ 7<\/pre><\/div>\n\n\n\n<ol class=\"wp-block-list\" start=\"14\">\n<li><strong>How can you make a property of a JavaScript object private?<\/strong> \n<ul class=\"wp-block-list\">\n<li>In JavaScript, we can&#8217;t make object properties truly private, but we can emulate this behavior using closures.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text\/javascript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;JavaScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;js&quot;}\">   function Person(name) {\n     var _name = name;\n\n     this.getName = function() {\n       return _name;\n     };\n   }\n\n   var john = new Person('John');\n   console.log(john.getName()); \/\/ &quot;John&quot;\n   console.log(john._name); \/\/ undefined<\/pre><\/div>\n\n\n\n<ol class=\"wp-block-list\" start=\"15\">\n<li><strong>What is a callback function in JavaScript?<\/strong> \n<ul class=\"wp-block-list\">\n<li>A callback function is a function that is passed as an argument to another function, to be &#8220;called back&#8221; at a later time.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text\/javascript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;JavaScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;js&quot;}\">   function greet(name, callback) {\n     console.log('Hello ' + name);\n     callback();\n   }\n\n   greet('John', function() {\n     console.log('The callback was invoked!');\n   });<\/pre><\/div>\n\n\n\n<ol class=\"wp-block-list\" start=\"16\">\n<li><strong>What is the difference between <code>==<\/code> and <code>===<\/code> in JavaScript?<\/strong> \n<ul class=\"wp-block-list\">\n<li><code>==<\/code> compares values after performing any necessary type conversions. <code>===<\/code> does not do any type conversion (so if two values are not the same type, <code>===<\/code> will simply return <code>false<\/code>).<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>What is the <code>map()<\/code> method in JavaScript?<\/strong> \n<ul class=\"wp-block-list\">\n<li>The <code>map()<\/code> method creates a new array with the results of calling a provided function on every element in the calling array.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text\/javascript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;JavaScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;js&quot;}\">   var numbers = [1, 4, 9];\n   var roots = numbers.map(Math.sqrt);\n   console.log(roots); \/\/ [1, 2, 3]<\/pre><\/div>\n\n\n\n<ol class=\"wp-block-list\" start=\"18\">\n<li><strong>What is the <code>reduce()<\/code> method in JavaScript?<\/strong> \n<ul class=\"wp-block-list\">\n<li>The <code>reduce()<\/code> method applies a function against an accumulator and each element in the array (from left to right) to reduce it to a single value.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text\/javascript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;JavaScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;js&quot;}\">   var numbers = [1, 2, 3, 4];\n   var sum = numbers.reduce(function(prev, curr) {\n     return prev + curr;\n   });\n   console.log(sum); \/\/ 10<\/pre><\/div>\n\n\n\n<ol class=\"wp-block-list\" start=\"19\">\n<li><strong>What are JavaScript Promises?<\/strong> \n<ul class=\"wp-block-list\">\n<li>A Promise is an object representing the eventual completion or failure of an asynchronous operation. Essentially, a promise is a returned object from a function, to which you attach callbacks, instead of passing callbacks into a function.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text\/javascript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;JavaScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;js&quot;}\">   var promise = new Promise(function(resolve, reject) {\n     var success = true;\n\n     if (success) {\n       resolve('Success!');\n     } else {\n       reject('Failure!');\n     }\n   });\n\n   promise.then(function(value) {\n     console.log(value); \/\/ &quot;Success!&quot;\n   }, function(value) {\n     console.log(value); \/\/ &quot;Failure!&quot;\n   });<\/pre><\/div>\n\n\n\n<ol class=\"wp-block-list\" start=\"20\">\n<li><strong>What are JavaScript generators?<\/strong> \n<ul class=\"wp-block-list\">\n<li>JavaScript generators are a special class of functions that simplify the task of writing iterators. A generator is a function that produces a sequence of results instead of a single value.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text\/javascript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;JavaScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;js&quot;}\">   function* idMaker() {\n     let id = 0;\n\n     while (true) {\n       yield id++;\n     }\n   }\n\n   const gen = idMaker();\n\n   console.log(gen.next().value); \/\/ 0\n   console.log(gen.next().value); \/\/ 1<\/pre><\/div>\n\n\n\n<ol class=\"wp-block-list\" start=\"21\">\n<li><strong>What is &#8216;use strict&#8217; in JavaScript?<\/strong> \n<ul class=\"wp-block-list\">\n<li>&#8216;use strict&#8217; is a literal expression that was introduced in ECMAScript 5, which helps you write safer JavaScript code by throwing an error if a global variable is created by mistake. For example:<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text\/javascript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;JavaScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;js&quot;}\">   'use strict';\n   x = 3.14; \/\/ This will cause an error because x is not declared<\/pre><\/div>\n\n\n\n<ol class=\"wp-block-list\" start=\"22\">\n<li><strong>What is a JavaScript Module?<\/strong> \n<ul class=\"wp-block-list\">\n<li>JavaScript modules are reusable pieces of code that can be exported from one program and imported for use in another program. Modules are particularly useful for a number of reasons: maintaining a code\u2019s organization, keeping the global scope clean, and for reusability.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text\/javascript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;JavaScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;js&quot;}\">   \/\/ lib.js\n   export function hello() {\n     return 'Hello, World!';\n   }\n\n   \/\/ main.js\n   import { hello } from '.\/lib';\n\n   console.log(hello()); \/\/ &quot;Hello, World!&quot;<\/pre><\/div>\n\n\n\n<ol class=\"wp-block-list\" start=\"23\">\n<li><strong>What is the difference between JavaScript&#8217;s <code>window<\/code>, <code>screen<\/code>, and <code>document<\/code> objects?<\/strong> \n<ul class=\"wp-block-list\">\n<li>The <code>window<\/code> object represents a window containing a DOM document. The <code>document<\/code> object represents the DOM in your web page. The <code>screen<\/code> object contains information about the user&#8217;s display.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>What is the JavaScript <code>event loop<\/code>?<\/strong> \n<ul class=\"wp-block-list\">\n<li>The event loop is a single-threaded loop that monitors the call stack and checks if there is any work to be done in the task queue. If the call stack is empty and there are callback functions in the task queue, a function is dequeued and pushed onto the call stack to be executed.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>What are <code>async<\/code> functions in JavaScript?<\/strong> \n<ul class=\"wp-block-list\">\n<li>Async functions enable us to write promise-based asynchronous code as if it were synchronous, but without blocking the main thread. They make code much cleaner and easy to read.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text\/javascript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;JavaScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;js&quot;}\">   async function myFunction() {\n     const value = await someAsyncOperation();\n     console.log(value);\n   }<\/pre><\/div>\n\n\n\n<ol class=\"wp-block-list\" start=\"26\">\n<li><strong>What are JavaScript <code>async<\/code>\/<code>await<\/code> keywords used for?<\/strong> \n<ul class=\"wp-block-list\">\n<li><code>async<\/code> and <code>await<\/code> make promises easier to write. <code>async<\/code> makes a function return a Promise, and <code>await<\/code> makes a function wait for a Promise.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text\/javascript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;JavaScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;js&quot;}\">   async function myFunction() {\n     const value = await someAsyncOperation();\n     console.log(value);\n   }<\/pre><\/div>\n\n\n\n<ol class=\"wp-block-list\" start=\"27\">\n<li><strong>What are JavaScript decorators?<\/strong> \n<ul class=\"wp-block-list\">\n<li>Decorators are a design pattern in JavaScript, achieved by annotating and modifying classes at design time.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text\/javascript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;JavaScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;js&quot;}\">   function readonly(target, key, descriptor) {\n     descriptor.writable = false;\n     return descriptor;\n   }\n\n   class Cat {\n     @readonly\n     meow() {\n       console.log('Meow!');\n     }\n   }\n\n   const cat = new Cat();\n   cat.meow = function() { console.log('Woof!')\n\n }; \/\/ Error: Cannot assign to read only property 'meow' ...<\/pre><\/div>\n\n\n\n<ol class=\"wp-block-list\" start=\"28\">\n<li><strong>What is a <code>Set<\/code> in JavaScript?<\/strong> \n<ul class=\"wp-block-list\">\n<li>A Set is a built-in JavaScript object that stores multiple values in a single variable. Set items are unique. Duplicates are not allowed.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text\/javascript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;JavaScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;js&quot;}\">   let mySet = new Set();\n   mySet.add(1); \n   mySet.add(2);\n   mySet.add(3);\n   mySet.add(2); \/\/ Duplicate, won't be added.\n   console.log(mySet); \/\/ Set(3)&amp;nbsp;{1, 2, 3}<\/pre><\/div>\n\n\n\n<ol class=\"wp-block-list\" start=\"29\">\n<li><strong>What is a <code>Map<\/code> in JavaScript?<\/strong> \n<ul class=\"wp-block-list\">\n<li>The <code>Map<\/code> object holds key-value pairs. Any value (both objects and primitive values) may be used as either a key or a value.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text\/javascript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;JavaScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;js&quot;}\">   let map = new Map();\n   map.set('name', 'John');\n   map.set('age', 25);\n   console.log(map.get('name')); \/\/ John\n   console.log(map.get('age')); \/\/ 25<\/pre><\/div>\n\n\n\n<ol class=\"wp-block-list\" start=\"30\">\n<li><strong>What are JavaScript Symbols?<\/strong> \n<ul class=\"wp-block-list\">\n<li>A Symbol is a unique and immutable primitive value and may be used as a key for an Object property.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text\/javascript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;JavaScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;js&quot;}\">   let sym1 = Symbol('Hello');\n   let sym2 = Symbol('Hello');\n   console.log(sym1 === sym2); \/\/ false, every symbol is unique<\/pre><\/div>\n\n\n\n<ol class=\"wp-block-list\" start=\"31\">\n<li><strong>What is the <code>instanceof<\/code> operator in JavaScript?<\/strong> \n<ul class=\"wp-block-list\">\n<li>The <code>instanceof<\/code> operator tests whether the prototype property of a constructor appears anywhere in the prototype chain of an object.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text\/javascript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;JavaScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;js&quot;}\">   function Car(make, model, year) {\n     this.make = make;\n     this.model = model;\n     this.year = year;\n   }\n\n   let auto = new Car('Honda', 'Accord', 1998);\n\n   console.log(auto instanceof Car);  \/\/ true<\/pre><\/div>\n\n\n\n<ol class=\"wp-block-list\" start=\"32\">\n<li><strong>What are JavaScript template literals?<\/strong> \n<ul class=\"wp-block-list\">\n<li>Template literals are string literals allowing embedded expressions. They were called &#8220;template strings&#8221; in prior editions of the ES2015 specification.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text\/javascript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;JavaScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;js&quot;}\">   let name = 'John';\n   console.log(`Hello, ${name}!`); \/\/ &quot;Hello, John!&quot;<\/pre><\/div>\n\n\n\n<ol class=\"wp-block-list\" start=\"33\">\n<li><strong>How can you share code between files?<\/strong> \n<ul class=\"wp-block-list\">\n<li>You can share code between files by exporting them from one file and importing them in another.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text\/javascript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;JavaScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;js&quot;}\">   \/\/ lib.js\n   export function hello() {\n     return 'Hello, World!';\n   }\n\n   \/\/ main.js\n   import { hello } from '.\/lib';\n\n   console.log(hello()); \/\/ &quot;Hello, World!&quot;<\/pre><\/div>\n\n\n\n<ol class=\"wp-block-list\" start=\"34\">\n<li><strong>Why you might want to create static class members?<\/strong> \n<ul class=\"wp-block-list\">\n<li>Static class members (properties\/methods) are not tied to a specific instance of a class and have the same value regardless of which instance is referred to. This can be useful when a value is shared across instances, for example, a software version number.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text\/javascript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;JavaScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;js&quot;}\">   class MyClass {\n     static myStaticValue = 'Hello, World!';\n\n     static myStaticMethod() {\n       return MyClass.myStaticValue;\n     }\n   }\n\n   console.log(MyClass.myStaticMethod()); \/\/ &quot;Hello, World!&quot;<\/pre><\/div>\n\n\n\n<ol class=\"wp-block-list\" start=\"35\">\n<li><strong>What is object destructuring in JavaScript?<\/strong> \n<ul class=\"wp-block-list\">\n<li>Destructuring assignment is a special syntax that allows us to &#8220;unpack&#8221; arrays or objects into a bunch of variables.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text\/javascript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;JavaScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;js&quot;}\">   let obj = { first: 'John', last: 'Doe' };\n   let {first: f, last: l} = obj;\n   console.log(f); \/\/ &quot;John&quot;\n   console.log(l); \/\/ &quot;Doe&quot;<\/pre><\/div>\n\n\n\n<ol class=\"wp-block-list\" start=\"36\">\n<li><strong>What are default parameters in JavaScript?<\/strong> \n<ul class=\"wp-block-list\">\n<li>Default function parameters allow formal parameters to be initialized with default values if no value or undefined is passed.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text\/javascript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;JavaScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;js&quot;}\">   function multiply(a, b = 1) {\n     return a * b;\n   }\n\n   console.log(multiply(5, 2)); \/\/ 10\n   console.log(multiply(5)); \/\/ 5, because b will default to 1<\/pre><\/div>\n\n\n\n<ol class=\"wp-block-list\" start=\"37\">\n<li><strong>What are rest parameters in JavaScript?<\/strong> \n<ul class=\"wp-block-list\">\n<li>The rest parameter syntax allows us to represent an indefinite number of arguments as an array.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text\/javascript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;JavaScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;js&quot;}\">   function sum(...args) {\n     return args.reduce((previous, current) =&gt; {\n       return previous + current;\n     });\n   }\n\n   console.log(sum(1, 2, 3, 4)); \/\/ 10<\/pre><\/div>\n\n\n\n<ol class=\"wp-block-list\" start=\"38\">\n<li><strong>What is JavaScript spread syntax?<\/strong> \n<ul class=\"wp-block-list\">\n<li>Spread syntax allows an iterable (like an array or string) to be expanded in places where zero or more arguments (for function calls) or elements (for array literals) are expected.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text\/javascript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;JavaScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;js&quot;}\">   let arr1 = [0, 1, 2];\n   let arr2 = [...arr1, 3, 4];\n   console.log(arr2); \/\/ [0, 1, 2, 3, 4]<\/pre><\/div>\n\n\n\n<ol class=\"wp-block-list\" start=\"39\">\n<li><strong>What are JavaScript Iterators?<\/strong> \n<ul class=\"wp-block-list\">\n<li>Iterators are objects which know how to access items from a collection one at a time, while keeping track of its current position within that sequence.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text\/javascript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;JavaScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;js&quot;}\">   const array1 = ['a', 'b', 'c'];\n\n   \/\/ Array elements iteration using the Iterator\n   let iterator1 = array1[Symbol.iterator]();\n\n   console.log(iterator1.next().value); \/\/ expected output: &quot;a&quot;\n   console.log(iterator1.next().value); \/\/ expected output: &quot;b&quot;\n   console.log(iterator1.next().value); \/\/ expected output: &quot;c&quot;<\/pre><\/div>\n\n\n\n<ol class=\"wp-block-list\" start=\"40\">\n<li><strong>How can you copy an object in JavaScript?<\/strong> \n<ul class=\"wp-block-list\">\n<li>One way to create a copy of an object is with the Object.assign() method.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text\/javascript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;JavaScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;js&quot;}\">   let obj = {a: 1, b: 2};\n   let copy = Object.assign({}, obj);\n   console.log(copy); \/\/ {a: 1, b: 2}<\/pre><\/div>\n\n\n\n<p>Another way is by using the spread syntax.<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text\/javascript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;JavaScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;js&quot;}\">   let obj = {a: 1, b: 2};\n   let copy = {...obj};\n   console.log(copy\n\n); \/\/ {a: 1, b: 2}<\/pre><\/div>\n\n\n\n<p>Note that these methods perform a shallow copy of the object. Nested objects are copied by reference, not duplicated.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here are 50 intermediate-level JavaScript questions along with their answers and code examples: Another way is by using the spread syntax. Note that these methods perform a shallow copy of the object. Nested objects are copied by reference, not duplicated.<\/p>\n","protected":false},"author":2,"featured_media":210,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[1],"tags":[11,26,25,10],"class_list":["post-73","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","tag-intermediate-level","tag-javascript","tag-js","tag-questions-and-answers"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/codeblog.xyz\/index.php?rest_route=\/wp\/v2\/posts\/73","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codeblog.xyz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codeblog.xyz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codeblog.xyz\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/codeblog.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=73"}],"version-history":[{"count":2,"href":"https:\/\/codeblog.xyz\/index.php?rest_route=\/wp\/v2\/posts\/73\/revisions"}],"predecessor-version":[{"id":83,"href":"https:\/\/codeblog.xyz\/index.php?rest_route=\/wp\/v2\/posts\/73\/revisions\/83"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/codeblog.xyz\/index.php?rest_route=\/wp\/v2\/media\/210"}],"wp:attachment":[{"href":"https:\/\/codeblog.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=73"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codeblog.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=73"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codeblog.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=73"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}