JavaScript Test 3

    Question 1: Boolean Conversion Rule

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

    Question 2: Logical OR with Truthy Values

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

    Question 3: Do-While Loop Execution

    What is the output?

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

    Question 4: Removing First Element

    What is the result of:

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

    Question 5: Function Expression Example

    Which of the following is a valid function expression?

    Question 6: Object.values()

    What will the following code output?

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

    Question 7: Function this in Non-Strict Mode

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

    Question 8: Appending Elements

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

    Question 9: Arrow Functions

    Which statement is true about arrow functions?

    Question 10: Async Function Return

    What does an async function always return?

    Question 11: Type of Symbol

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

    Question 12: Assignment with Addition

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

    Question 13: For...of Loop

    What is the output?

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

    Question 14: Adding First Element

    What is the result of:

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

    Question 15: Scope of Variables

    Which variable has function scope in JavaScript?

    Question 16: Checking Property Existence

    Which operator checks if an object has a given property?

    Question 17: this with call()

    What does the following print?

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

    Question 18: Changing Attributes

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

    Question 19: Destructuring Assignment

    What is the value of x after this code?

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

    Question 20: Await Keyword

    What does the await keyword do?