JavaScript Test 3

    Question 1Boolean Conversion Rule

    Which of the following values converts to false when used in Boolean conversion?

    Question 2Logical OR with Truthy Values

    What is the result of 0 || "Hello" in JavaScript?

    Question 3Do-While Loop Execution

    What is the output?

    let i = 5; do { console.log(i); i++; } while (i < 5);

    Question 4Removing First Element

    What is the result of:

    let arr = [10, 20, 30]; arr.shift(); console.log(arr);

    Question 5Function Expression Example

    Which of the following is a valid function expression?

    Question 6Object.values()

    What will the following code output?

    let car = { brand: "Tesla", model: "X" }; console.log(Object.values(car));

    Question 7Function this in Non-Strict Mode

    In non-strict mode, what does this refer to inside a standalone function?

    Question 8Appending Elements

    How do you add a newly created element p to the body?

    Question 9Arrow Functions

    Which statement is true about arrow functions?

    Question 10Async Function Return

    What does an async function always return?

    Question 11Type of Symbol

    What is the type of Symbol("id")?

    Question 12Assignment with Addition

    If let a = 5; a += 3; then what is the value of a?

    Question 13For...of Loop

    What is the output?

    let arr = ["a", "b", "c"]; for (let val of arr) { console.log(val); }

    Question 14Adding First Element

    What is the result of:

    let arr = [20, 30]; arr.unshift(10); console.log(arr);

    Question 15Scope of Variables

    Which variable has function scope in JavaScript?

    Question 16Checking Property Existence

    Which operator checks if an object has a given property?

    Question 17this with call()

    What does the following print?

    function greet() { console.log(this.language); } greet.call({ language: "JavaScript" });

    Question 18Changing Attributes

    How can you change the src attribute of an image with ID pic?

    Question 19Destructuring Assignment

    What is the value of x after this code?

    let [x, y] = [10, 20];

    Question 20Await Keyword

    What does the await keyword do?