JavaScript Test 2

    Question 1Type of BigInt

    What is the type of the value 123n in JavaScript?

    Question 2Strict Equality Operator

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

    Question 3For Loop Execution

    How many times will this loop run?

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

    Question 4Adding Elements with push()

    What is the result of:

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

    Question 5Anonymous Functions

    An anonymous function is a function that:

    Question 6Adding Properties

    Which code correctly adds a property age with value 25 to an object user?

    Question 7this in Object Method

    What does the following code output?

    let person = { name: "Alice", greet: function() { console.log(this.name); } }; person.greet();

    Question 8Modifying Text Content

    How do you change the text inside an element with ID title?

    Question 9Template Literals

    How do you create a string using template literals?

    Question 10then() Method

    What is the purpose of .then() in a Promise?

    Question 11Type Conversion to Number

    What is the result of Number("123abc")?

    Question 12Logical AND

    What is the result of true && false?

    Question 13JS While Loop

    What is the output?

    let i = 0; while (i < 3) { console.log(i); i++; }

    Question 14Removing Last Element

    What is the result of:

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

    Question 15Function Hoisting

    Which type of function gets hoisted completely in JavaScript?

    Question 16Object.keys()

    What does Object.keys(obj) return?

    Question 17this in Arrow Functions

    What is special about this in arrow functions?

    Question 18Creating Elements

    Which method creates a new HTML element?

    Question 19Default Parameters

    What will add(5) return if the function is defined as:

    function add(a, b = 10) { return a + b; }

    Question 20catch() Method

    What does .catch() do in a Promise chain?