Explore key concepts and features of asynchronous programming in…
Start QuizExplore underrated JavaScript libraries that offer powerful solutions for…
Start QuizExplore how pnpm 10 enhances package installation security and…
Start QuizExplore how JavaScript classes relate to prototypes, constructor functions,…
Start QuizDiscover the proven patterns and practical habits that distinguish…
Start QuizAssess your understanding of JavaScript modules, including import/export syntax,…
Start QuizChallenge your understanding of JavaScript function definitions, syntax, and…
Start QuizSharpen your understanding of JavaScript objects with these easy…
Start QuizExplore the basics of JavaScript loops with these straightforward…
Start QuizExplore easy questions covering fundamental JavaScript concepts, suitable for…
Start QuizExplore the basics of the JavaScript Event Loop, including…
Start QuizChallenge your JavaScript fundamentals with 15 essential interview questions…
Start QuizExplore essential concepts for handling dependencies across multi-package JavaScript…
Start QuizChallenge your understanding of fundamental JavaScript concepts with these…
Start QuizExplore the history and evolution of JavaScript, from its…
Start QuizEnhance your understanding of JavaScript with this beginner-friendly quiz…
Start QuizTest your understanding of common internet troubleshooting scenarios and…
Start QuizTest your knowledge of ES6 (ECMAScript 2015) features with…
Start QuizTest your understanding of key JavaScript topics with these…
Start QuizTest your knowledge with these commonly asked JavaScript interview…
Start QuizTest your knowledge of Observables in JavaScript, including their…
Start QuizTest your knowledge of essential JavaScript developer tips and…
Start QuizTest your knowledge of JavaScript ES6 features with this…
Start QuizTest your understanding of core JavaScript concepts relevant to…
Start QuizChallenge your understanding of JavaScript functions, scoping rules, closures, recursion, and related advanced concepts. Ideal for those looking to test or refine their mastery of these fundamental topics.
This quiz contains 16 questions. Below is a complete reference of all questions, answer choices, and correct answers. You can use this section to review after taking the interactive quiz above.
What is the output of the following code? console.log(add(2, 3)); function add(a, b) { return a + b; }
Correct answer: 5
Given the code below, what happens when calling multiply(2, 4) before its definition? console.log(multiply(2, 4)); var multiply = function(a, b) { return a * b; };
Correct answer: TypeError
In the context of arrow functions, how is the value of 'this' determined when called inside an object method?
Correct answer: 'this' is taken from the enclosing lexical scope
What value is assigned to y in function call myFunc(undefined) given this definition? function myFunc(y = 7) { return y; }
Correct answer: 7
Which syntax correctly allows a function to accept any number of arguments as an array named items?
Correct answer: function collect(...items) {}
What is logged after executing the following? { let x = 10; } console.log(typeof x);
Correct answer: "undefined"
Which output will result from this code? function outer() { let counter = 0; return function() { counter++; return counter; }; } const inc = outer(); inc(); inc(); console.log(inc());
Correct answer: 3
Given this recursive factorial implementation, what does factorial(3) return? function factorial(n) { if (n === 0) return 1; else return n * factorial(n - 1); }
Correct answer: 6
What is the value of typeof bar inside the following function expression? const bar = function baz() { return typeof baz; };
Correct answer: "function"
What will the following code log to the console? let y = 5; (function() { let y = 10; console.log(y); })(); console.log(y);
Correct answer: 10 then 5
What is logged by this code? function foo(a) { a = 4; } let b = 3; foo(b); console.log(b);
Correct answer: 3
Which pattern immediately executes a function upon definition?
Correct answer: (function(){ /* code */ })();
What is the value of arguments[0] inside an arrow function?
Correct answer: ReferenceError
What happens when a recursive function lacks an explicit base case in JavaScript?
Correct answer: It eventually throws a RangeError due to stack overflow
Given function test(a = 2) { return a; }, what is the output of test()?
Correct answer: 2
If obj = {val: 2, getVal: () => this.val}, what is the result of calling obj.getVal()?
Correct answer: undefined