JavaScript Test 1

    Question 1: JavaScript Data Type of typeof null

    What is the result of typeof null in JavaScript?

    Question 2: Arithmetic Operator Precedence

    What is the result of 10 + 5 * 2 in JavaScript?

    Question 3: If-Else Condition

    What will be the output of:

    let x = 10; if (x > 15) { console.log("Big"); } else { console.log("Small"); }

    Question 4: Array Type

    What is the result of typeof [] in JavaScript?

    Question 5: Normal Function Declaration

    Which of the following correctly declares a normal function in JavaScript?

    Question 6: Creating Objects

    Which of the following correctly creates an object in JavaScript?

    Question 7: Global this in Browser

    What does this refer to in the global scope in a browser?

    Question 8: Accessing Element by ID

    Which method is used to get an element by its ID?

    Question 9: let vs var

    What is the main difference between let and var?

    Question 10: Promise States

    Which of the following is NOT a state of a JavaScript Promise?

    Question 11: Checking Not-a-Number (NaN)

    Which of the following is true about NaN in JavaScript?

    Question 12: Comparison with Equality

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

    Question 13: Switch Statement Default

    What will be the output?

    let fruit = "apple"; switch(fruit) { case "banana": console.log("Yellow"); break; case "orange": console.log("Orange"); break; default: console.log("Unknown"); }

    Question 14: Array Length Property

    What will be the output of:

    let arr = [1, 2, 3]; console.log(arr.length);

    Question 15: Arrow Function Syntax

    Which is the correct syntax of an arrow function that returns the sum of a and b?

    Question 16: Accessing Properties

    How do you access the value of property name in the object person?

    Question 17: Global this in Strict Mode

    What does this refer to in global scope under "use strict"?

    Question 18: Accessing Multiple Elements

    Which method returns a live HTMLCollection of elements with a given class name?

    Question 19: const Declaration

    Which statement about const is correct?

    Question 20: Creating a Promise

    How do you create a new Promise?