How to take the questions:
JavaScript:
- Read each question carefully and select either A, B, C, or D by clicking on your chosen option.
- A 3-second countdown will begin after you select your answer, giving you a moment to review your choice.
- Your answer will be marked instantly as CORRECT! or OOPS! with feedback provided.
- The next question will then be revealed automatically. At the end, you will see your final score with the number of correct and incorrect answers.
- You can click PLAY AGAIN to retake the quiz and improve your score.
QUESTION 1 OF 20
The === operator in JavaScript compares two values for equality without performing type coercion. What does this operator compare?
What will be the output of console.log(typeof null);?
A developer needs to execute a block of code repeatedly as long as a condition remains true, with the number of iterations being unknown. Which loop structure is most appropriate?
How can you declare a variable in JavaScript that cannot be reassigned after its initial value is set?
When a function is defined inside another function, it has access to the outer function's variables even after the outer function has returned. What is this concept called?
What will be the output of the following code? let x = 10; function test() { console.log(x); let x = 20; } test();
A developer is working with an object and wants to iterate over its enumerable property keys. Which loop is specifically designed for this purpose?
Which array method creates a new array with all elements that pass a test implemented by a provided function?
In JavaScript, functions are considered first-class citizens. What does this imply about functions?
What will be the value of result after this code executes? const result = [1, 2, 3].map(num => num * 2);
A developer needs to handle asynchronous operations in a way that resembles synchronous code, avoiding "callback hell". Which modern JavaScript feature should be used?
What is the output of console.log(5 + '5');?
In JavaScript, functions have a special property that refers to the object it is a method of. What is this property called?
Which method is used to merge two or more objects into a single new object by copying properties from source objects to a target object?
When designing a system where objects need to inherit properties from a common parent, what is the underlying mechanism of inheritance in JavaScript?
What will be the output of the following code? const promise = new Promise((resolve, reject) => { console.log('A'); resolve('B'); console.log('C'); }); promise.then(console.log); console.log('D');
A developer has an array and wants to transform it into a single value, such as the sum of all its elements. Which higher-order function is most appropriate for this operation?
What is the primary purpose of the Symbol data type introduced in ES6?
A function that returns a new function, capturing variables from its outer scope, is known as what?
What is the result of the following code? function Person(name) { this.name = name; } Person.prototype.greet = function() { return 'Hello, ' + this.name; }; const john = new Person('John'); console.log(john.greet());
QUIZ DONE!
0%
✅ 0
❌ 0
Variables and Data Types
JavaScript is a versatile, high-level programming language that serves as the backbone of modern web development. At its core, JavaScript manages data through variables declared using var, let, or const—each with distinct scoping and reassignment rules. The language supports several data types, including primitives like strings, numbers, booleans, null, undefined, and symbols, as well as complex types like objects and arrays. Understanding operators and comparisons is essential, as JavaScript's type coercion can lead to unexpected results, making the strict equality operator (===) a best practice over loose equality (==). Functions are first-class citizens, meaning they can be assigned to variables, passed as arguments, and returned from other functions, while scope determines where variables are accessible—global, function, or block scope. JavaScript also employs hoisting, where variable and function declarations are moved to the top of their scope during compilation, though let and const remain in a temporal dead zone until initialization.
Advanced Concepts and Asynchronous Programming
Moving beyond the basics, JavaScript's arrays and array methods provide powerful tools for data manipulation, including map(), filter(), reduce(), and forEach(), enabling functional programming paradigms. Objects and prototypes form the foundation of JavaScript's inheritance model, where objects can inherit properties and methods from other objects through the prototype chain, offering a flexible alternative to classical inheritance. Closures allow functions to retain access to variables from their outer scope even after the outer function has returned, enabling patterns like data encapsulation and factory functions.
Asynchronous JavaScript is critical for handling operations like API calls and timers without blocking execution; Promises and the async/await syntax provide cleaner, more readable ways to manage asynchronous workflows compared to traditional callbacks. Loops and iteration structures like for, while, do...while, for...in, and for...of give developers fine control over repetitive tasks. Finally, ES6 features such as arrow functions, template literals, destructuring, and the Symbol data type have modernized the language, making code more concise, expressive, and maintainable. Mastering these concepts equips developers to build robust, efficient, and scalable applications across both client-side and server-side environments using Node.js.
