{"id":1508,"date":"2021-11-08T09:34:06","date_gmt":"2021-11-08T09:34:06","guid":{"rendered":"https:\/\/usemynotes.com\/?p=1508"},"modified":"2025-04-25T22:37:24","modified_gmt":"2025-04-25T17:07:24","slug":"javascript-interview-questions-and-answers","status":"publish","type":"post","link":"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/","title":{"rendered":"JavaScript Interview Questions and Answers 2025"},"content":{"rendered":"<p>Hi guys, welcome back. In this module, I will be discussing the top 50 <strong>JavaScript Interview Questions and Answers<\/strong>. Destructuring in JavaScript was covered in the previous module. You can read our previous module if you want to know about it. So, let\u2019s get started to know JavaScript Interview Questions and Answers.<\/p>\n<p><img decoding=\"async\" class=\"alignnone wp-image-1509 size-full\" src=\"https:\/\/usemynotes.com\/wp-content\/uploads\/2021\/11\/javascript-interview-questions-and-answers.jpg\" alt=\"JavaScript Interview Questions and Answers\" width=\"1000\" height=\"700\" title=\"\" srcset=\"https:\/\/usemynotes.com\/wp-content\/uploads\/2021\/11\/javascript-interview-questions-and-answers.jpg 1000w, https:\/\/usemynotes.com\/wp-content\/uploads\/2021\/11\/javascript-interview-questions-and-answers-300x210.jpg 300w, https:\/\/usemynotes.com\/wp-content\/uploads\/2021\/11\/javascript-interview-questions-and-answers-768x538.jpg 768w, https:\/\/usemynotes.com\/wp-content\/uploads\/2021\/11\/javascript-interview-questions-and-answers-150x105.jpg 150w, https:\/\/usemynotes.com\/wp-content\/uploads\/2021\/11\/javascript-interview-questions-and-answers-696x487.jpg 696w, https:\/\/usemynotes.com\/wp-content\/uploads\/2021\/11\/javascript-interview-questions-and-answers-600x420.jpg 600w, https:\/\/usemynotes.com\/wp-content\/uploads\/2021\/11\/javascript-interview-questions-and-answers-100x70.jpg 100w\" sizes=\"(max-width: 1000px) 100vw, 1000px\" \/><\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_80 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 eztoc-toggle-hide-by-default' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/#List_of_50_Most_Asked_JavaScript_Interview_Questions_and_Answers\" >List of 50 Most Asked JavaScript Interview Questions and Answers<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/#1_Mention_the_different_data_types_in_JavaScript\" >1. Mention the different data types in JavaScript.<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/#Primitive_Data_types\" >Primitive Data types<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/#Non-primitive_data_types\" >Non-primitive data types<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/#2_Define_hoisting_in_JavaScript\" >2. Define hoisting in JavaScript.<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/#3_Mention_the_difference_between_%E2%80%98_%E2%80%98\" >3. Mention the difference between \u2018==\u2019 &amp; \u2018===\u2019.<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/#4_Is_JavaScript_a_dynamically_typed_language\" >4. Is JavaScript a dynamically typed language?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/#5_What_is_the_usage_of_isNaN_in_JavaScript\" >5. What is the usage of isNaN in JavaScript?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/#6_In_JavaScript_what_do_you_mean_by_%E2%80%9Cthis%E2%80%9D_keyword\" >6. In JavaScript, what do you mean by &#8220;this&#8221; keyword?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/#7_How_can_the_style_of_an_HTML_element_be_changed_using_JavaScript\" >7. How can the style of an HTML element be changed using JavaScript?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/#8_What_would_be_the_output_of_the_JavaScript_code_given_below\" >8. What would be the output of the JavaScript code given below?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/#9_Mention_the_different_types_of_pop-up_boxes_in_JavaScript\" >9. Mention the different types of pop-up boxes in JavaScript.<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/#10_Define_undefined_in_JavaScript\" >10. Define undefined in JavaScript.<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/#11_Define_null_in_JavaScript\" >11. Define null in JavaScript.<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/#12_What_is_the_usage_of_typeof_operator_in_JavaScript\" >12. What is the usage of typeof operator in JavaScript?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-16\" href=\"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/#13_What_is_DOM_in_JavaScript\" >13. What is DOM in JavaScript?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-17\" href=\"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/#14_What_are_the_methods_for_accessing_manipulating_the_document_object_model_DOM\" >14. What are the methods for accessing &amp; manipulating the document object model (DOM)?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-18\" href=\"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/#15_What_is_the_difference_between_push_unshift_methods_of_an_array_in_JavaScript\" >15. What is the difference between push &amp; unshift methods of an array in JavaScript?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-19\" href=\"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/#16_What_is_the_use_of_for-in_loop_in_JavaScript\" >16. What is the use of for-in loop in JavaScript?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-20\" href=\"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/#17_What_is_the_difference_between_pop_shift_method_of_arrays_in_JavaScript\" >17. What is the difference between pop() &amp; shift method of arrays in JavaScript?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-21\" href=\"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/#18_What_is_the_difference_between_innerHTML_innerText_in_JavaScript\" >18. What is the difference between innerHTML &amp; innerText in JavaScript?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-22\" href=\"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/#19_Name_the_methods_used_for_printing_the_message_on_the_HTML_document\" >19. Name the method(s) used for printing the message on the HTML document.<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-23\" href=\"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/#20_What_is_an_arrow_function\" >20. What is an arrow function?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-24\" href=\"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/#21_What_is_meant_by_destructuring_in_JavaScript\" >21. What is meant by destructuring in JavaScript?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-25\" href=\"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/#22_What_would_be_the_output_of_the_JavaScript_code_given_below\" >22. What would be the output of the JavaScript code given below?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-26\" href=\"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/#23_How_many_different_ways_may_JavaScript_be_included_in_an_HTML_file\" >23. How many different ways may JavaScript be included in an HTML file?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-27\" href=\"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/#24_Mention_the_differences_between_Java_JavaScript\" >24. Mention the differences between Java &amp; JavaScript.<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-28\" href=\"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/#25_What_are_the_different_methods_for_defining_variables_in_JavaScript\" >25. What are the different methods for defining variables in JavaScript?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-29\" href=\"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/#26_Define_callback_function_in_JavaScript\" >26. Define callback function in JavaScript.<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-30\" href=\"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/#27_Mention_the_use_of_void0_in_JavaScript\" >27. Mention the use of void(0) in JavaScript.<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-31\" href=\"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/#28_How_can_I_use_JavaScript_to_find_the_Operating_system_on_the_client_machine\" >28. How can I use JavaScript to find the Operating system on the client machine?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-32\" href=\"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/#29_How_to_check_the_status_of_checkboxes_in_JavaScript\" >29. How to check the status of checkboxes in JavaScript?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-33\" href=\"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/#30_How_to_detect_the_browser_which_is_running_the_web_page\" >30. How to detect the browser which is running the web page?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-34\" href=\"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/#31_How_can_a_user_be_redirected_to_a_different_page_using_JavaScript\" >31. How can a user be redirected to a different page using JavaScript?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-35\" href=\"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/#32_Predict_the_output_of_the_following_JavaScript_code_on_execution\" >32. Predict the output of the following JavaScript code on execution.<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-36\" href=\"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/#33_Name_the_various_types_of_errors_in_JavaScript\" >33. Name the various types of errors in JavaScript.<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-37\" href=\"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/#34_Mention_the_difference_between_indexOf_and_lastindexOf_method_in_JavaScript\" >34. Mention the difference between indexOf() and lastindexOf() method in JavaScript.<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-38\" href=\"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/#35_Write_a_JavaScript_code_for_adding_new_elements_dynamically\" >35. Write a JavaScript code for adding new elements dynamically.<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-39\" href=\"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/#36_How_can_you_submit_a_form_using_JavaScript\" >36. How can you submit a form using JavaScript?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-40\" href=\"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/#37_In_JavaScript_how_do_we_create_read_a_cookie\" >37. In JavaScript, how do we create &amp; read a cookie?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-41\" href=\"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/#38_In_JavaScript_how_may_Generic_objects_be_created\" >38. In JavaScript, how may Generic objects be created?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-42\" href=\"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/#39_Predict_the_output_of_the_following_JavaScript_code_when_executed\" >39. Predict the output of the following JavaScript code when executed.<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-43\" href=\"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/#40_Predict_the_result_of_the_following_JavaScript_code_when_executed\" >40. Predict the result of the following JavaScript code when executed.<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-44\" href=\"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/#41_Will_the_given_JavaScript_code_produce_an_error\" >41. Will the given JavaScript code produce an error?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-45\" href=\"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/#42_What_will_be_the_output_of_the_following_Script_when_executed\" >42. What will be the output of the following Script when executed?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-46\" href=\"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/#43_What_will_be_the_output_of_the_following_JavaScript_when_executed\" >43. What will be the output of the following JavaScript when executed?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-47\" href=\"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/#44_What_will_be_the_result_of_the_following_JavaScript_when_executed\" >44. What will be the result of the following JavaScript when executed?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-48\" href=\"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/#45_Predict_the_result_of_the_JavaScript_code_given_below\" >45. Predict the result of the JavaScript code given below.<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-49\" href=\"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/#46_How_can_you_create_an_array_in_JavaScript\" >46. How can you create an array in JavaScript?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-50\" href=\"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/#47_How_can_you_create_objects_in_JavaScript\" >47. How can you create objects in JavaScript?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-51\" href=\"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/#48_What_are_some_of_the_frameworks_for_JavaScript\" >48. What are some of the frameworks for JavaScript?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-52\" href=\"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/#49_In_JavaScript_what_method_is_used_to_remove_focus_from_a_specific_object\" >49. In JavaScript, what method is used to remove focus from a specific object?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-53\" href=\"https:\/\/usemynotes.com\/javascript-interview-questions-and-answers\/#50_Predict_the_output_of_both_functions\" >50. Predict the output of both functions.<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"List_of_50_Most_Asked_JavaScript_Interview_Questions_and_Answers\"><\/span>List of 50 Most Asked JavaScript Interview Questions and Answers<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><span class=\"ez-toc-section\" id=\"1_Mention_the_different_data_types_in_JavaScript\"><\/span>1. Mention the different data types in JavaScript.<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<h4><span class=\"ez-toc-section\" id=\"Primitive_Data_types\"><\/span>Primitive Data types<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<ul>\n<li>Number<\/li>\n<li>Boolean<\/li>\n<li>String<\/li>\n<li>Undefined<\/li>\n<li>Symbol<\/li>\n<li>Null<\/li>\n<\/ul>\n<h4><span class=\"ez-toc-section\" id=\"Non-primitive_data_types\"><\/span>Non-primitive data types<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<ul>\n<li>Object<\/li>\n<li>Array<\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"2_Define_hoisting_in_JavaScript\"><\/span>2. Define hoisting in JavaScript.<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>This is the second question of the top 50 JavaScript Interview Questions and Answers. Hoisting is <a href=\"https:\/\/usemynotes.com\/what-is-javascript\/\">Javascript<\/a> default behaviour in which all variable and function declarations are moved to the top.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"3_Mention_the_difference_between_%E2%80%98_%E2%80%98\"><\/span>3. Mention the difference between \u2018==\u2019 &amp; \u2018===\u2019.<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>This is the third question of the top 50 JavaScript Interview Questions and Answers. \u2018==\u2019 returns true if two values are same whereas \u2018===\u2019 returns true if the data type &amp; value of a variable are the same.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">var a = 3, b = '3';\r\nconsole.log(a==b);\r\nconsole.log(a===b);\r\n\/\/ Output\r\n\/\/ true\r\n\/\/ false<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"4_Is_JavaScript_a_dynamically_typed_language\"><\/span>4. Is JavaScript a dynamically typed language?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>This is the 4th question of the top 50 JavaScript Interview Questions and Answers. Yes, because the data type of variables is decided at runtime, JavaScript is a dynamically typed language.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"5_What_is_the_usage_of_isNaN_in_JavaScript\"><\/span>5. What is the usage of isNaN in JavaScript?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>This is the 5th question of the top 50 JavaScript Interview Questions and Answers. NaN stands for \u201cNot a Number\u201d. It returns true if the given value is not a number, otherwise false.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">console.log(isNaN(5.5));\r\nconsole.log(isNaN('hello'));\r\nconsole.log(isNaN(true));\r\n\/\/ Output\r\n\/\/ false\r\n\/\/ true\r\n\/\/ false<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"6_In_JavaScript_what_do_you_mean_by_%E2%80%9Cthis%E2%80%9D_keyword\"><\/span>6. In JavaScript, what do you mean by &#8220;this&#8221; keyword?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>This is the 6th question of the top 50 JavaScript Interview Questions and Answers. \u2018this\u2019 keyword in JavaScript refers to the <a href=\"https:\/\/usemynotes.com\/object-in-javascript\/\">object<\/a> from where it was called. Depending on where it is used, the &#8220;this&#8221; has multiple values. It refers to the owner object in a method and the global object in a function.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"7_How_can_the_style_of_an_HTML_element_be_changed_using_JavaScript\"><\/span>7. How can the style of an HTML element be changed using JavaScript?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>The style of a HTML element can be changed in 2 ways:<\/p>\n<ul>\n<li><strong>setAttribute() method<\/strong><br \/>\nelement.setAttriute(&#8216;style&#8217;, cssProperty);<br \/>\nFor example,<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">element.setAttribute(&quot;style&quot;, &quot;background-color: yellow;&quot;);<\/pre>\n<\/li>\n<li><strong>style property<\/strong><br \/>\nelement.style.cssProperty = value;<br \/>\nFor example,<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">element.style.background=&quot;yellow&quot;;<\/pre>\n<\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"8_What_would_be_the_output_of_the_JavaScript_code_given_below\"><\/span>8. What would be the output of the JavaScript code given below?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">console.log(5+3+'6');\r\n\/\/ Output\r\n\/\/ 86<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"9_Mention_the_different_types_of_pop-up_boxes_in_JavaScript\"><\/span>9. Mention the different types of pop-up boxes in JavaScript.<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>There are 3 types of pop-up boxes in<\/p>\n<ul>\n<li><strong>alert()<\/strong><br \/>\nFor example,<br \/>\nalert(&#8216;Alert Box&#8217;);<\/li>\n<li><strong>prompt()<\/strong><br \/>\nFor example,<br \/>\nconst value = prompt(&#8216;Enter a value:&#8217;);<br \/>\nconsole.log(value);<\/li>\n<li><strong>confirm()<\/strong><br \/>\nFor example,<br \/>\nconst value = confirm(&#8220;Do you want to continue?&#8221;);<br \/>\nconsole.log(value);<\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"10_Define_undefined_in_JavaScript\"><\/span>10. Define undefined in JavaScript.<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>This is the 10th question of the top 50 JavaScript Interview Questions and Answers. In JavaScript, undefined signifies that a variable has been declared but not assigned a value or that it has not been declared at all.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"11_Define_null_in_JavaScript\"><\/span>11. Define null in JavaScript.<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>This is the 11th question of the top 50 JavaScript Interview Questions and Answers. Null in JavaScript represents the absence of any value. It can be assigned to a variable to indicate that it currently has no value but will do so in the future.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"12_What_is_the_usage_of_typeof_operator_in_JavaScript\"><\/span>12. What is the usage of typeof operator in JavaScript?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>This is the 12th question of the top 50 JavaScript Interview Questions and Answers. typeof operator is used for checking the data type of a variable or value.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">const x = 5, y = 'Hello';\r\nconsole.log(typeof x, typeof y);\r\n\/\/ Output\r\n\/\/ number string<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"13_What_is_DOM_in_JavaScript\"><\/span>13. What is DOM in JavaScript?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>This is the 13th question of the top 50 JavaScript Interview Questions and Answers. <a href=\"https:\/\/usemynotes.com\/dom-in-javascript\/\">DOM <\/a>stands for Document Object Model. It is a hierarchical representation of an HTML document.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"14_What_are_the_methods_for_accessing_manipulating_the_document_object_model_DOM\"><\/span>14. What are the methods for accessing &amp; manipulating the document object model (DOM)?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ul>\n<li>document.getElementById(idName)<\/li>\n<li>document.getElementsByClass(className)<\/li>\n<li>document.getElementsByTagName(TagName)<\/li>\n<li>document.querySelector(cssSelector)<\/li>\n<li>document.getElementsByName(name);<\/li>\n<li>document.querySelectorAll(cssSelector)<\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"15_What_is_the_difference_between_push_unshift_methods_of_an_array_in_JavaScript\"><\/span>15. What is the difference between push &amp; unshift methods of an array in JavaScript?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>This is the 15th question of the top 50 JavaScript Interview Questions and Answers. push() method is an array method used for inserting an element at the end of an array.<br \/>\nFor example,<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">const arr = &#x5B;-4, 9, -7, 11, 19];\r\nconsole.log(arr);\r\narr.push(6);\r\nconsole.log(arr);\r\n\/\/ Output\r\n\/\/ &#x5B;-4, 9, -7, 11, 19]\r\n\/\/ &#x5B;-4, 9, -7, 11, 19, 6]<\/pre>\n<p>unshift() method is an array method used for inserting an element at the beginning of an array.<br \/>\nFor example,<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">const arr = &#x5B;-4, 9, -7, 11, 19];\r\nconsole.log(arr);\r\narr.unshift(6);\r\nconsole.log(arr);\r\n\/\/ Output\r\n\/\/ &#x5B;-4, 9, -7, 11, 19]\r\n\/\/ &#x5B;6, -4, 9, -7, 11, 19]<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"16_What_is_the_use_of_for-in_loop_in_JavaScript\"><\/span>16. What is the use of for-in loop in JavaScript?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>This is the 16th question of the top 50 JavaScript Interview Questions and Answers. The for-in loop in JavaScript is used for iterating through the properties of an object.<br \/>\nSyntax<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">for(let variableName in objectName){\r\n\/\/ do something\r\n}\r\nFor example,\r\nvar person = {\r\n  name: &quot;Shikhar Gupta&quot;,\r\n  age: 22,\r\n  gender: &quot;Male&quot;,\r\n  email:&quot;shikhar@xyz.com&quot;\r\n};\r\nfor(let key in person)\r\n{\r\n  console.log(key, person&#x5B;key]);\r\n}\r\n\/\/Output\r\n\/\/name Shikhar Gupta\r\n\/\/age 22\r\n\/\/gender Male\r\n\/\/email shikhar@xyz.com<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"17_What_is_the_difference_between_pop_shift_method_of_arrays_in_JavaScript\"><\/span>17. What is the difference between pop() &amp; shift method of arrays in JavaScript?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>This is the 17th question of the top 50 JavaScript Interview Questions and Answers. The pop() method is an <a href=\"https:\/\/usemynotes.com\/arrays-in-javascript\/\">array<\/a> method used for deleting an element at the end of an array.<br \/>\nFor example,<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">const arr = &#x5B;-4, 9, -7, 11, 19];\r\nconsole.log(arr);\r\narr.pop();\r\nconsole.log(arr);\r\n\/\/ Output\r\n\/\/ &#x5B;-4, 9, -7, 11, 19]\r\n\/\/ &#x5B;-4, 9, -7, 11]<\/pre>\n<p>shift() method is an array method used for deleting an element at the beginning of an array.<br \/>\nFor example,<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">const arr = &#x5B;-4, 9, -7, 11, 19];\r\nconsole.log(arr);\r\narr.shift();\r\nconsole.log(arr);\r\n\/\/ Output\r\n\/\/ &#x5B;-4, 9, -7, 11, 19]\r\n\/\/ &#x5B;9, -7, 11, 19]<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"18_What_is_the_difference_between_innerHTML_innerText_in_JavaScript\"><\/span>18. What is the difference between innerHTML &amp; innerText in JavaScript?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>This is the 18th question of the top 50 JavaScript Interview Questions and Answers. The innerText is an attribute used to retrieve and set the content of an HTML element or tag, the spaces are not taken into consideration. It is not possible to use HTML tags when using it; otherwise, plain text will be written.<\/p>\n<p>The innerHTML attribute is used to print or change HTML and the text contained within them as well as to set the content of HTML components. The spaces are also included. HTML tags can also be inserted.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"19_Name_the_methods_used_for_printing_the_message_on_the_HTML_document\"><\/span>19. Name the method(s) used for printing the message on the HTML document.<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ul>\n<li>document.write()<br \/>\nFor example,<br \/>\ndocument.write(&#8216;Hello, World!&#8217;);<\/li>\n<li>document.writeln()<br \/>\nFor example,<br \/>\ndocument.writeln(&#8216;Hello, World!&#8217;);<\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"20_What_is_an_arrow_function\"><\/span>20. What is an arrow function?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>This is the 20th question of the top 50 JavaScript Interview Questions and Answers. An <a href=\"https:\/\/usemynotes.com\/what-is-arrow-function-in-javascript\/\">arrow function<\/a> is a short syntax or concise way of writing user-defined functions in JavaScript. This feature was introduced in ES6 or ECMAScript 2015.<br \/>\nFor example,<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">let fun = () =&gt; {\r\n  console.log ('This is an example of the JavaScript arrow function.');\r\n}\r\nfun ();\r\n\/\/ Output\r\n\/\/ This is an example of the JavaScript arrow function.<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"21_What_is_meant_by_destructuring_in_JavaScript\"><\/span>21. What is meant by destructuring in JavaScript?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>This is the 21st question of the top 50 JavaScript Interview Questions and Answers. <a href=\"https:\/\/usemynotes.com\/destructuring-in-javascript\/\">Destructuring in JavaScript<\/a> is used to extract or retrieve multiple values from an object &amp; array.<\/p>\n<ul>\n<li><strong>Array destructuring<\/strong>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">let arr = &#x5B;1, 3, -4, 10];\r\nlet &#x5B;a, b, c, d] = arr;\r\nconsole.log(a, b, c ,d);\r\n\/\/ Output\r\n\/\/ 1 3 -4 10<\/pre>\n<\/li>\n<li><strong>Object destructuring<\/strong>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">let person = {\r\n  name:&quot;Samar Singh&quot;,\r\n  age: 21,\r\n  gender: 'Male'\r\n}const {name, age, gender} = person;\r\nconsole.log(name, age, gender);\r\n\/\/ Output\r\n\/\/ Rahul Sharma 22 Male<\/pre>\n<\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"22_What_would_be_the_output_of_the_JavaScript_code_given_below\"><\/span>22. What would be the output of the JavaScript code given below?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">let a = {}, b = {name:&quot;Rohit&quot;}, c = {name:&quot;Singh&quot;};\r\na&#x5B;b] = {name:&quot;Vivan&quot;};\r\nb&#x5B;c] = {name:&quot;Akshay&quot;};\r\nconsole.log(a&#x5B;c]);\r\n\/\/ Output\r\n\/\/ {name: 'Vivan'}<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"23_How_many_different_ways_may_JavaScript_be_included_in_an_HTML_file\"><\/span>23. How many different ways may JavaScript be included in an HTML file?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>This is the 23rd question of the top 50 JavaScript Interview Questions and Answers. A JavaScript code can be included in an HTML file in three distinct ways:<\/p>\n<ul>\n<li>Inline<\/li>\n<li>External<\/li>\n<li>Internal<\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"24_Mention_the_differences_between_Java_JavaScript\"><\/span>24. Mention the differences between Java &amp; JavaScript.<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<figure class=\"wp-block-table\">\n<table>\n<tbody>\n<tr>\n<th style=\"text-align: center;\">Java<\/th>\n<th style=\"text-align: center;\">JavaScript<\/th>\n<\/tr>\n<tr>\n<td>Java is an object-oriented programming (OOP) language.<\/td>\n<td>JavaScript is an object-oriented scripting language used both client-side &amp; server-side.<\/td>\n<\/tr>\n<tr>\n<td>It develops applications that run in a virtual machine or a web browser.<\/td>\n<td>It develops applications that run in a web browser.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<h3><span class=\"ez-toc-section\" id=\"25_What_are_the_different_methods_for_defining_variables_in_JavaScript\"><\/span>25. What are the different methods for defining variables in JavaScript?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>This is the 25th question of the top 50 JavaScript Interview Questions and Answers. There are 3 different methods for defining <a href=\"https:\/\/usemynotes.com\/what-are-variables-in-javascript\/\">variables<\/a> in JavaScript:<\/p>\n<ul>\n<li>var<\/li>\n<li>let<\/li>\n<li>const<\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"26_Define_callback_function_in_JavaScript\"><\/span>26. Define callback function in JavaScript.<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>This is the 26th question of the top 50 JavaScript Interview Questions and Answers. A callback function is a function that is executed after the execution of another <a href=\"https:\/\/usemynotes.com\/what-are-functions-in-javascript\/\">function<\/a>. It is also defined as a function that is passed as an argument to another function.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"27_Mention_the_use_of_void0_in_JavaScript\"><\/span>27. Mention the use of void(0) in JavaScript.<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>This is the 27th question of the top 50 JavaScript Interview Questions and Answers. void(0) is used for preventing the page from refreshing or reloading.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"28_How_can_I_use_JavaScript_to_find_the_Operating_system_on_the_client_machine\"><\/span>28. How can I use JavaScript to find the Operating system on the client machine?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>This is the 28th question of the top 50 JavaScript Interview Questions and Answers. We can use a navigator.appVersion property to find the Operating system on the client machine.<br \/>\nconsole.log(navigator.appVersion);<\/p>\n<h3><span class=\"ez-toc-section\" id=\"29_How_to_check_the_status_of_checkboxes_in_JavaScript\"><\/span>29. How to check the status of checkboxes in JavaScript?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>This is the 29th question of the top 50 JavaScript Interview Questions and Answers. We can use the checked property to check the status of the checkbox in JavaScript.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"30_How_to_detect_the_browser_which_is_running_the_web_page\"><\/span>30. How to detect the browser which is running the web page?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>This is the 30th question of the top 50 JavaScript Interview Questions and Answers. The window object navigator is used to determine the browser in which the web page is presently executing.<br \/>\nconsole.log(navigator.appName);<\/p>\n<h3><span class=\"ez-toc-section\" id=\"31_How_can_a_user_be_redirected_to_a_different_page_using_JavaScript\"><\/span>31. How can a user be redirected to a different page using JavaScript?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>This is the 31st question of the top 50 JavaScript Interview Questions and Answers. The window object location can be used to redirect the user to the new page.<br \/>\nwindow.location.href=https:\/\/www.usemynotes.com\/;<\/p>\n<h3><span class=\"ez-toc-section\" id=\"32_Predict_the_output_of_the_following_JavaScript_code_on_execution\"><\/span>32. Predict the output of the following JavaScript code on execution.<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">var x = 10;\r\n(function () {\r\n  console.log(&quot;Initial Number &quot; + x);\r\n  var x = 20;\r\n  console.log(&quot;New Number &quot; + x);\r\n})();\r\n\r\n\/\/ Output\r\n\/\/ Initial Number undefined\r\n\/\/ New Number 20<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"33_Name_the_various_types_of_errors_in_JavaScript\"><\/span>33. Name the various types of errors in JavaScript.<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ul>\n<li>Runtime errors<\/li>\n<li>Load time errors<\/li>\n<li>Logical errors<\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"34_Mention_the_difference_between_indexOf_and_lastindexOf_method_in_JavaScript\"><\/span>34. Mention the difference between indexOf() and lastindexOf() method in JavaScript.<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><strong>indexOf()<\/strong><br \/>\nIt returns the position or index in a string of the first occurrence of the specified text.<\/p>\n<p><strong>lastIndexOf()<\/strong><br \/>\nIt returns the index of the last occurrence of specified text in a string.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">let str = &quot;Hello world&quot;;\r\nconsole.log(str.indexOf(&quot;l&quot;));\r\nconsole.log(str.lastIndexOf(&quot;l&quot;));\r\n\r\n\/\/ Output\r\n\/\/ 2\r\n\/\/ 9<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"35_Write_a_JavaScript_code_for_adding_new_elements_dynamically\"><\/span>35. Write a JavaScript code for adding new elements dynamically.<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n  &lt;title&gt;Elements Dynamically&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;button id=&quot;btn&quot;&gt;Click Me&lt;\/button&gt;\r\n&lt;script&gt;\r\nconst button = document.querySelector('#btn');\r\nbutton.addEventListener('click',()=&gt;{\r\n  var p = document.createElement('h1');\r\n  var text = document.createTextNode('Add content dynamically using JavaScript');\r\n  p(text);\r\n  document.body(p);\r\n});\r\n&lt;\/script&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"36_How_can_you_submit_a_form_using_JavaScript\"><\/span>36. How can you submit a form using JavaScript?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>This is the 36th question of the top 50 JavaScript Interview Questions and Answers. For submitting a form using JavaScript, we can use document.form[0].submit() method.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"37_In_JavaScript_how_do_we_create_read_a_cookie\"><\/span>37. In JavaScript, how do we create &amp; read a cookie?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>We can use property to create &amp; read a cookie in JavaScript.<br \/>\ndocument.cookie = &#8220;username=Raman Singh&#8221;;<br \/>\nconsole.log(document.cookie);<\/p>\n<h3><span class=\"ez-toc-section\" id=\"38_In_JavaScript_how_may_Generic_objects_be_created\"><\/span>38. In JavaScript, how may Generic objects be created?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>var genericObject = new Object();<\/p>\n<h3><span class=\"ez-toc-section\" id=\"39_Predict_the_output_of_the_following_JavaScript_code_when_executed\"><\/span>39. Predict the output of the following JavaScript code when executed.<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">console.log(false == '0')\r\nconsole.log(false === '0')\r\n\/\/ Output\r\n\/\/ true\r\n\/\/ false<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"40_Predict_the_result_of_the_following_JavaScript_code_when_executed\"><\/span>40. Predict the result of the following JavaScript code when executed.<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">var a = 21;\r\nvar fun = function () {\r\n  console.log(a);\r\n  var a = 40;\r\n};\r\nfun ();\r\n\r\n\/\/ Output\r\n\/\/ undefined<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"41_Will_the_given_JavaScript_code_produce_an_error\"><\/span>41. Will the given JavaScript code produce an error?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">var arr = &#x5B;3, 2, 5];\r\nconsole.log(arr&#x5B;4]);\r\nNo, the above code does not produce an error.\r\n\/\/ Output\r\n\/\/ undefined<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"42_What_will_be_the_output_of_the_following_Script_when_executed\"><\/span>42. What will be the output of the following Script when executed?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">console.log(typeof undefined===typeof null);\r\n\/\/ Output\r\n\/\/ false<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"43_What_will_be_the_output_of_the_following_JavaScript_when_executed\"><\/span>43. What will be the output of the following JavaScript when executed?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">console.log(typeof typeof 2.4);\r\n\/\/ Output\r\n\/\/ string<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"44_What_will_be_the_result_of_the_following_JavaScript_when_executed\"><\/span>44. What will be the result of the following JavaScript when executed?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">var x = 1;\r\nfunction outerFunction(){\r\n  var x = 5;\r\n  function innerFunction(){\r\n    x++;\r\n    var x = 8;\r\n    console.log(x)\r\n  }\r\n  innerFunction();\r\n}\r\nouterFunction();\r\n\/\/ Output\r\n\/\/ 8<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"45_Predict_the_result_of_the_JavaScript_code_given_below\"><\/span>45. Predict the result of the JavaScript code given below.<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">console.log(4 &lt; 5 &lt; 6);\r\nconsole.log(6 &gt; 5 &gt; 4);\r\n\/\/ Output\r\n\/\/ true\r\n\/\/ false<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"46_How_can_you_create_an_array_in_JavaScript\"><\/span>46. How can you create an array in JavaScript?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><strong>Using array literal<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">const a = &#x5B;1, 3, 7];<\/pre>\n<p><strong>Using new keyword<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">var arr = new Array();\r\narr&#x5B;0]=3;\r\narr&#x5B;3]=1;\r\narr&#x5B;1]=5;\r\nconsole.log(arr);\r\nvar a = new Array(3, 1.5, &quot;Java&quot;);\r\nconsole.log(a);<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"47_How_can_you_create_objects_in_JavaScript\"><\/span>47. How can you create objects in JavaScript?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><strong>Using object literal<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">let person = {\r\n  name:&quot;Neha Singh&quot;,\r\n  age: 25,\r\n  gender: 'Female'\r\n}<\/pre>\n<p><strong>Using new keyword<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">var person=new Object();\r\nperson.name='Shikhar Gupta';\r\nperson.age='24';\r\nconsole.log(person);<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"48_What_are_some_of_the_frameworks_for_JavaScript\"><\/span>48. What are some of the frameworks for JavaScript?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>This is the 48th question of the top 50 JavaScript Interview Questions and Answers. React, Angular &amp; Vue are some of the JavaScript frameworks.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"49_In_JavaScript_what_method_is_used_to_remove_focus_from_a_specific_object\"><\/span>49. In JavaScript, what method is used to remove focus from a specific object?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>This is the 49th question of the top 50 JavaScript Interview Questions and Answers. In JavaScript, the Blur function is used for removing focus from an object.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"50_Predict_the_output_of_both_functions\"><\/span>50. Predict the output of both functions.<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">function fun1()\r\n{\r\n  return {\r\n    message: &quot;hello&quot;\r\n  };\r\n}\r\n\r\nfunction fun2()\r\n{\r\n  return\r\n {\r\n    message: &quot;hello&quot;\r\n  };\r\n}\r\nconsole.log(fun1());\r\nconsole.log(fun2());\r\n\/\/ Output\r\n\/\/ {message: 'hello'}\r\n\/\/ undefined<\/pre>\n<p>I hope the <strong>JavaScript Interview Questions and Answers<\/strong> module will be beneficial for your interviews. There are many other questions in JavaScript, but it is not possible to discuss them in a single module. You can read other programming languages tutorials &amp; blogs on our website if you want more informative modules like this.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi guys, welcome back. In this module, I will be discussing the top 50 JavaScript Interview Questions and Answers. Destructuring in JavaScript was covered in the previous module. You can read our previous module if you want to know about it. So, let\u2019s get started to know JavaScript Interview Questions and Answers. List of 50 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1509,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[],"class_list":{"0":"post-1508","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-javascript"},"_links":{"self":[{"href":"https:\/\/usemynotes.com\/wp-json\/wp\/v2\/posts\/1508","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/usemynotes.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/usemynotes.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/usemynotes.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/usemynotes.com\/wp-json\/wp\/v2\/comments?post=1508"}],"version-history":[{"count":0,"href":"https:\/\/usemynotes.com\/wp-json\/wp\/v2\/posts\/1508\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/usemynotes.com\/wp-json\/wp\/v2\/media\/1509"}],"wp:attachment":[{"href":"https:\/\/usemynotes.com\/wp-json\/wp\/v2\/media?parent=1508"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/usemynotes.com\/wp-json\/wp\/v2\/categories?post=1508"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/usemynotes.com\/wp-json\/wp\/v2\/tags?post=1508"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}