JavaScript Test 1

    Question 1JavaScript Data Type of typeof null

    What is the result of typeof null in JavaScript?

    Question 2Arithmetic Operator Precedence

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

    Question 3If-Else Condition

    What will be the output of:

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

    Question 4Array Type

    What is the result of typeof [] in JavaScript?

    Question 5Normal Function Declaration

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

    Question 6Creating Objects

    Which of the following correctly creates an object in JavaScript?

    Question 7Global this in Browser

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

    Question 8Accessing Element by ID

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

    Question 9let vs var

    What is the main difference between let and var?

    Question 10Promise States

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

    Question 11Checking Not-a-Number (NaN)

    Which of the following is true about NaN in JavaScript?

    Question 12Comparison with Equality

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

    Question 13Switch 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 14Array Length Property

    What will be the output of:

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

    Question 15Arrow Function Syntax

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

    Question 16Accessing Properties

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

    Question 17Global this in Strict Mode

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

    Question 18Accessing Multiple Elements

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

    Question 19const Declaration

    Which statement about const is correct?

    Question 20Creating a Promise

    How do you create a new Promise?