JavaScript Test 5

    Question 1: Undefined Value Type

    What is the type of undefined in JavaScript?

    Question 2: Unary Increment

    What is the result of:

    let a = 5; let b = ++a;

    Question 3: JS Continue Statement

    What is the output?

    for (let i = 0; i < 5; i++) { if (i === 2) continue; console.log(i); }

    Question 4: Array isArray Method

    What is the result of:

    console.log(Array.isArray([1, 2, 3]));

    Question 5: JS Default Parameters

    What will greet("Alice") print if the function is defined as:

    function greet(name = "Guest") { console.log(name); }

    Question 6: JS For...in Loop

    What is the output?

    let obj = {a:1, b:2}; for (let key in obj) { console.log(key); }

    Question 7: Types of Execution Context

    Which of the following are types of execution context in JavaScript?

    Question 8: Query Selector

    Which method selects the first element that matches a CSS selector?

    Question 9: Rest Parameters

    Which function correctly uses rest parameters to accept multiple arguments?

    Question 10: Multiple await Statements

    How does execution behave with multiple await statements?

    Question 11: Equality with Type Conversion

    What is the result of 0 == "0" in JavaScript?

    Question 12: Exponentiation Operator

    What is the result of 2 ** 3 in JavaScript?

    Question 13: Nested Loop Execution

    How many times will "Hello" be printed?

    for (let i = 0; i < 2; i++) { for (let j = 0; j < 3; j++) { console.log("Hello"); } }

    Question 14: Array Concatenation

    What will be the result of:

    let a = [1, 2]; let b = [3, 4]; console.log(a.concat(b));

    Question 15: Hoisting with Function Expressions

    What happens if you call a function expression before it is defined?

    greet(); var greet = function() { console.log("Hello"); };

    Question 16: Object.assign()

    What does Object.assign(target, source) do?

    Question 17: this Inside a Class

    What does the following code output?

    class Car { constructor(name) { this.name = name; } showName() { console.log(this.name); } } let c = new Car("Tesla"); c.showName();

    Question 18: querySelectorAll vs getElementsByClassName

    What is the difference between querySelectorAll and getElementsByClassName?

    Question 19: Modules Export/Import

    How do you export a function in ES6 module?

    Question 20: Converting Promise to Async/Await

    Which of the following is equivalent to:

    fetchData().then(data => console.log(data)).catch(err => console.log(err));