{"id":71,"date":"2023-09-06T17:34:10","date_gmt":"2023-09-06T16:34:10","guid":{"rendered":"https:\/\/codeblog.xyz\/?p=71"},"modified":"2023-10-23T20:29:52","modified_gmt":"2023-10-23T17:29:52","slug":"50-simple-javascript-questions","status":"publish","type":"post","link":"https:\/\/codeblog.xyz\/?p=71","title":{"rendered":"50 simple javascript questions"},"content":{"rendered":"\n<p>Here are 50 simple Javascript questions along with their answers and code examples:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>What is the output of <code>console.log(5 + \"5\")<\/code> in JavaScript?<\/strong> \n<ul class=\"wp-block-list\">\n<li>This will output <code>55<\/code>. Because one operand is a string, JavaScript will convert the other operand to a string before performing the concatenation.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>What is the output of <code>console.log(5 - \"5\")<\/code> in JavaScript?<\/strong> \n<ul class=\"wp-block-list\">\n<li>This will output <code>0<\/code>. JavaScript performs type coercion and converts the string <code>\"5\"<\/code> to the number <code>5<\/code>, then does the subtraction.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>What is the output of <code>console.log(5 == \"5\")<\/code> in JavaScript?<\/strong> \n<ul class=\"wp-block-list\">\n<li>This will output <code>true<\/code>. The double equals <code>==<\/code> operator performs type coercion if the types on both sides are different.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>What is the output of <code>console.log(5 === \"5\")<\/code> in JavaScript?<\/strong> \n<ul class=\"wp-block-list\">\n<li>This will output <code>false<\/code>. The triple equals <code>===<\/code> operator does not perform type coercion.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Write a function to reverse a string in JavaScript.<\/strong><\/li>\n<\/ul>\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 reverseString(str) {\n     return str.split('').reverse().join('');\n   }<\/pre><\/div>\n\n\n\n<ul class=\"wp-block-list\" start=\"6\">\n<li><strong>How do you declare a variable in JavaScript?<\/strong><\/li>\n<\/ul>\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 myVariable = &quot;Hello&quot;;\n   let myVariable = &quot;Hello&quot;;\n   const myVariable = &quot;Hello&quot;;<\/pre><\/div>\n\n\n\n<ul class=\"wp-block-list\" start=\"7\">\n<li><strong>What is a callback function in JavaScript?<\/strong> A callback function is a function passed into another function as an argument, which is then invoked inside the outer function.<\/li>\n<\/ul>\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('This is a callback');\n   });<\/pre><\/div>\n\n\n\n<ul class=\"wp-block-list\" start=\"8\">\n<li><strong>What is closure in JavaScript?<\/strong> \n<ul class=\"wp-block-list\">\n<li>A closure is a function having access to the parent scope, even after the parent function has closed.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\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 outer() {\n     var x = 10;\n     function inner() {\n       console.log(x);\n     }\n     return inner;\n   }\n\n   var innerFunc = outer();\n   innerFunc(); \/\/ Output: 10<\/pre><\/div>\n\n\n\n<ul class=\"wp-block-list\" start=\"9\">\n<li><strong>How do you write a for loop in JavaScript?<\/strong><\/li>\n<\/ul>\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;}\">   for (var i = 0; i &lt; 5; i++) {\n     console.log(i);\n   }<\/pre><\/div>\n\n\n\n<ul class=\"wp-block-list\" start=\"10\">\n<li><strong>How do you write an if-else statement in JavaScript?<\/strong> <\/li>\n<\/ul>\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 x = 10; \n\nif (x &gt; 5) \n{ \n  console.log(&quot;x is greater than 5&quot;); \n} else { \n  console.log(&quot;x is not greater than 5&quot;); \n}<\/pre><\/div>\n\n\n\n<ul class=\"wp-block-list\" start=\"10\">\n<li><strong>How do you declare a function in JavaScript?<\/strong> <\/li>\n<\/ul>\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 myFunction() { \n  console.log(&quot;Hello World&quot;); \n}<\/pre><\/div>\n\n\n\n<ul class=\"wp-block-list\" start=\"10\">\n<li><strong>How do you add an item to an array in JavaScript?<\/strong> <\/li>\n<\/ul>\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 arr = [1, 2, 3]; \narr.push(4);<\/pre><\/div>\n\n\n\n<ul class=\"wp-block-list\" start=\"10\">\n<li><strong>How do you remove an item from an array in JavaScript?<\/strong> <\/li>\n<\/ul>\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 arr = [1, 2, 3]; \narr.pop(); \/\/ Removes last element<\/pre><\/div>\n\n\n\n<ul class=\"wp-block-list\" start=\"10\">\n<li><strong>How do you check if a variable is an array in JavaScript?<\/strong> <\/li>\n<\/ul>\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 arr = [1, 2, 3]; \nconsole.log(Array.isArray(arr)); \/\/ true<\/pre><\/div>\n\n\n\n<ul class=\"wp-block-list\" start=\"10\">\n<li><strong>How can you concatenate strings in JavaScript?<\/strong> <\/li>\n<\/ul>\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 str1 = &quot;Hello&quot;; \nvar str2 = &quot;World&quot;; console.log(str1 + &quot; &quot; + str2); \/\/ &quot;Hello World&quot;<\/pre><\/div>\n\n\n\n<ul class=\"wp-block-list\" start=\"10\">\n<li><strong>How do you declare an object in JavaScript?<\/strong> <\/li>\n<\/ul>\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 obj = { name: &quot;John&quot;, age: 30 };<\/pre><\/div>\n\n\n\n<ul class=\"wp-block-list\" start=\"10\">\n<li><strong>How do you access properties of an object in JavaScript?<\/strong> <\/li>\n<\/ul>\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 obj = { name: &quot;John&quot;, age: 30 }; \nconsole.log(obj.name); \/\/ &quot;John&quot; console.log(obj['age']); \/\/ 30<\/pre><\/div>\n\n\n\n<ul class=\"wp-block-list\" start=\"10\">\n<li><strong>What is the output of <code>console.log(null == undefined)<\/code> in JavaScript?<\/strong> \n<ul class=\"wp-block-list\">\n<li>This will output <code>true<\/code> because <code>==<\/code> operator performs type coercion and both <code>null<\/code> and <code>undefined<\/code> are falsy values.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>What is the output of <code>console.log(null === undefined)<\/code> in JavaScript?<\/strong> \n<ul class=\"wp-block-list\">\n<li>This will output <code>false<\/code> because <code>===<\/code> operator doesn&#8217;t perform type coercion.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>How do you check if a variable is undefined in JavaScript?<\/strong> <\/li>\n<\/ul>\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 myVar; if (typeof myVar === 'undefined') { console.log('myVar is undefined'); }<\/pre><\/div>\n\n\n\n<ul class=\"wp-block-list\" start=\"10\">\n<li><strong>What is &#8216;use strict&#8217; in JavaScript?<\/strong> \n<ul class=\"wp-block-list\">\n<li><code>'use strict'<\/code> is a directive introduced in ECMAScript 5. It helps catch common coding mistakes and &#8220;unsafe&#8221; actions by throwing exceptions.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\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 throw an error because x is not declared<\/pre><\/div>\n\n\n\n<ul class=\"wp-block-list\" start=\"22\">\n<li><strong>What is the difference between <code>let<\/code>, <code>const<\/code>, and <code>var<\/code>?<\/strong> \n<ul class=\"wp-block-list\">\n<li><code>var<\/code> is function scoped, and if it is declared outside a function it is globally scoped. <code>let<\/code> and <code>const<\/code> are block scoped. <code>const<\/code> is a read-only reference to a value.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>What are arrow functions in JavaScript?<\/strong> \n<ul class=\"wp-block-list\">\n<li>Arrow functions are a shorthand syntax for writing function expressions. They cannot be used as constructors and do not have their own <code>this<\/code>, <code>arguments<\/code>, <code>super<\/code>, or <code>new.target<\/code>.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\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 sum = (a, b) =&gt; a + b;<\/pre><\/div>\n\n\n\n<ul class=\"wp-block-list\" start=\"24\">\n<li><strong>What are JavaScript Promises?<\/strong> \n<ul class=\"wp-block-list\">\n<li>A Promise in JavaScript is an object representing the eventual completion or failure of an asynchronous operation. A Promise is in one of three states: pending, fulfilled, or rejected.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\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 promise = new Promise(function(resolve, reject) {\n     \/\/ the function is executed automatically when the promise is constructed\n\n     \/\/ after 1 second signal that the job is done with the result &quot;done&quot;\n     setTimeout(() =&gt; resolve(&quot;done&quot;), 1000);\n   });<\/pre><\/div>\n\n\n\n<ul class=\"wp-block-list\" start=\"25\">\n<li><strong>What is a JavaScript Promise <code>then<\/code> method?<\/strong> \n<ul class=\"wp-block-list\">\n<li>The <code>then<\/code> method returns a Promise. It takes two arguments, both are callback functions for the success and failure cases respectively.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\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 promise = new Promise((resolve, reject) =&gt; {\n     setTimeout(() =&gt; {\n       resolve(&quot;Resolved!&quot;);\n     }, 1000);\n   });\n\n   promise.then(value =&gt; console.log(value)); \/\/ &quot;Resolved!&quot;<\/pre><\/div>\n\n\n\n<ul class=\"wp-block-list\" start=\"26\">\n<li><strong>What is a JavaScript Promise <code>catch<\/code> method?<\/strong> \n<ul class=\"wp-block-list\">\n<li>The <code>catch<\/code> method returns a Promise and deals with rejected cases only.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\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 promise = new Promise((resolve, reject) =&gt; {\n     setTimeout(() =&gt; {\n       reject(&quot;Rejected!&quot;);\n     }, 1000);\n   });\n\n   promise.catch(reason =&gt; console.log(reason)); \/\/ &quot;Rejected!&quot;<\/pre><\/div>\n\n\n\n<ul class=\"wp-block-list\" start=\"27\">\n<li><strong>What is JavaScript `async\/await`?<\/strong><\/li>\n<\/ul>\n\n\n\n<p>The <code>async<\/code> function declaration defines an asynchronous function, which returns an AsyncFunction object. The <code>await<\/code> operator is used to wait for a Promise.<\/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;}\">   async function myFunction() {\n     const promise = new Promise((resolve, reject) =&gt; {\n       setTimeout(() =&gt; resolve(&quot;Hello&quot;), 1000);\n     });\n\n     const result = await promise; \/\/ wait until the promise resolves\n     console.log(result); \/\/ &quot;Hello&quot;\n   }\n\n   myFunction();<\/pre><\/div>\n\n\n\n<ul class=\"wp-block-list\" start=\"28\">\n<li><strong>What is the difference between <code>==<\/code> and <code>===<\/code> in JavaScript?<\/strong> \n<ul class=\"wp-block-list\">\n<li>The <code>==<\/code> operator will compare for equality after doing any necessary type conversions. The <code>===<\/code> operator will not do the 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>How do you add a property to an object in JavaScript?<\/strong><\/li>\n<\/ul>\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 obj = {\n     name: &quot;John&quot;,\n     age: 30\n   };\n   obj.job = &quot;Developer&quot;;\n   console.log(obj); \/\/ {name: &quot;John&quot;, age: 30, job: &quot;Developer&quot;}<\/pre><\/div>\n\n\n\n<ul class=\"wp-block-list\" start=\"30\">\n<li><strong>How do you delete a property from an object in JavaScript?<\/strong><\/li>\n<\/ul>\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 obj = {\n     name: &quot;John&quot;,\n     age: 30,\n     job: &quot;Developer&quot;\n   };\n   delete obj.job;\n   console.log(obj); \/\/ {name: &quot;John&quot;, age: 30}<\/pre><\/div>\n\n\n\n<ul class=\"wp-block-list\" start=\"31\">\n<li><strong>What is <code>NaN<\/code> in JavaScript?<\/strong> \n<ul class=\"wp-block-list\">\n<li><code>NaN<\/code> is a special value in JavaScript that stands for &#8220;Not a Number&#8221;. It is the returned value when Math functions fail or when a function trying to parse a number fails.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\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(0 \/ 0); \/\/ NaN<\/pre><\/div>\n\n\n\n<ul class=\"wp-block-list\" start=\"32\">\n<li><strong>How do you check if a value is <code>NaN<\/code> in JavaScript?<\/strong><\/li>\n<\/ul>\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(isNaN(0 \/ 0)); \/\/ true<\/pre><\/div>\n\n\n\n<ul class=\"wp-block-list\" start=\"33\">\n<li><strong>What is an IIFE (Immediately Invoked Function Expression) in JavaScript?<\/strong> \n<ul class=\"wp-block-list\">\n<li>An IIFE is a JavaScript function that runs as soon as it is defined.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\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     console.log('Hello World');\n   })();<\/pre><\/div>\n\n\n\n<ul class=\"wp-block-list\" start=\"34\">\n<li><strong>What is the difference between null and undefined in JavaScript?<\/strong> \n<ul class=\"wp-block-list\">\n<li><code>null<\/code> is an assignment value. It means no value or no object. It is not an identifier for a property of an object or for a variable itself. <code>undefined<\/code> means a variable has been declared but has not yet been assigned a value.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>How to get a random number between 1 and 100 in JavaScript?<\/strong><\/li>\n<\/ul>\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 randomNum = Math.floor(Math.random() * 100) + 1;\n   console.log(randomNum);<\/pre><\/div>\n\n\n\n<ul class=\"wp-block-list\" start=\"36\">\n<li><strong>How can you convert a string to an integer in JavaScript?<\/strong><\/li>\n<\/ul>\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 str = &quot;123&quot;;\n   var int = parseInt(str);\n   console.log(int); \/\/ 123<\/pre><\/div>\n\n\n\n<ul class=\"wp-block-list\" start=\"37\">\n<li><strong>How can you convert a string to a number in JavaScript?<\/strong><\/li>\n<\/ul>\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 str = &quot;123.45&quot;;\n   var num = parseFloat(str);\n   console.log(num); \/\/ 123.45<\/pre><\/div>\n\n\n\n<ul class=\"wp-block-list\" start=\"38\">\n<li><strong>What are JavaScript data types?<\/strong> \n<ul class=\"wp-block-list\">\n<li>JavaScript data types include Number, String, Boolean, Object, Function, Null, Undefined, and Symbol (in ES6).<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>How can you get the type of a variable in JavaScript?<\/strong><\/li>\n<\/ul>\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 str = &quot;Hello&quot;;\n   console.log(typeof str); \/\/ &quot;string&quot;<\/pre><\/div>\n\n\n\n<ul class=\"wp-block-list\" start=\"40\">\n<li><strong>What is JSON in JavaScript?<\/strong> \n<ul class=\"wp-block-list\">\n<li>JSON (JavaScript Object Notation) is a lightweight data-interchange format that is easy for humans to read and write and easy for machines to parse and generate. It is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>How do you parse JSON in JavaScript?<\/strong><\/li>\n<\/ul>\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 json = '{&quot;name&quot;:&quot;John&quot;, &quot;age&quot;:30, &quot;city&quot;:&quot;New York&quot;}';\n   var obj = JSON.parse(json);\n   console.log(obj.name); \/\/ &quot;John&quot;<\/pre><\/div>\n\n\n\n<ul class=\"wp-block-list\" start=\"42\">\n<li><strong>How do you convert an object to a JSON string in JavaScript?<\/strong><\/li>\n<\/ul>\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 obj = {name: &quot;John&quot;, age: 30, city: &quot;New York&quot;};\n   var json = JSON.stringify(obj);\n   console.log(json); \/\/ '{&quot;name&quot;:&quot;John&quot;, &quot;age&quot;:30, &quot;city&quot;:&quot;New York&quot;}'<\/pre><\/div>\n\n\n\n<ul class=\"wp-block-list\" start=\"43\">\n<li><strong>How do you create a date object in JavaScript?<\/strong><\/li>\n<\/ul>\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 date = new Date();\n   console.log(date);<\/pre><\/div>\n\n\n\n<ul class=\"wp-block-list\" start=\"44\">\n<li><strong>How do you get the current time in JavaScript?<\/strong><\/li>\n<\/ul>\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 date = new Date();\n   console.log(date.getTime());<\/pre><\/div>\n\n\n\n<ul class=\"wp-block-list\" start=\"45\">\n<li><strong>How do you get the current date in JavaScript?<\/strong><\/li>\n<\/ul>\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 date = new Date();\n   console.log(date.toDateString());<\/pre><\/div>\n\n\n\n<ul class=\"wp-block-list\" start=\"46\">\n<li><strong>What are JavaScript events?<\/strong> \n<ul class=\"wp-block-list\">\n<li>JavaScript events are actions that can be detected by JavaScript. For example, a user clicking a button is an event.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>How do you prevent the default action of an event in JavaScript?<\/strong><\/li>\n<\/ul>\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;}\">   element.addEventListener('click', function(event) {\n     event.preventDefault();\n     \/\/ do something\n   });<\/pre><\/div>\n\n\n\n<ul class=\"wp-block-list\" start=\"48\">\n<li><strong>How do you attach an event handler to an element in JavaScript?<\/strong><\/li>\n<\/ul>\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 button = document.querySelector('button');\n   button.addEventListener('click', function() {\n     console.log('Button clicked');\n   });<\/pre><\/div>\n\n\n\n<ul class=\"wp-block-list\" start=\"49\">\n<li><strong>How do you get the value of an input field in JavaScript?<\/strong><\/li>\n<\/ul>\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 input = document.querySelector('input');\n   console.log(input.value);<\/pre><\/div>\n\n\n\n<ul class=\"wp-block-list\" start=\"50\">\n<li><strong>How do you change the content of an HTML element in JavaScript?<\/strong><\/li>\n<\/ul>\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 element = document.querySelector('p');\n   element.textContent = 'New content';<\/pre><\/div>\n\n\n\n<p>I hope these questions will help you in learning JavaScript. Happy coding!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here are 50 simple Javascript questions along with their answers and code examples: The async function declaration defines an asynchronous function, which returns an AsyncFunction object. The await operator is used to wait for a Promise. I hope these questions will help you in learning JavaScript. Happy coding!<\/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":[12,26,25,10],"class_list":["post-71","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","tag-beginner-level","tag-javascript","tag-js","tag-questions-and-answers"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/codeblog.xyz\/index.php?rest_route=\/wp\/v2\/posts\/71","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=71"}],"version-history":[{"count":5,"href":"https:\/\/codeblog.xyz\/index.php?rest_route=\/wp\/v2\/posts\/71\/revisions"}],"predecessor-version":[{"id":81,"href":"https:\/\/codeblog.xyz\/index.php?rest_route=\/wp\/v2\/posts\/71\/revisions\/81"}],"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=71"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codeblog.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=71"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codeblog.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=71"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}