JavaScript Test 2

    Question 1: Type of BigInt

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

    Question 2: Strict Equality Operator

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

    Question 3: For Loop Execution

    How many times will this loop run?

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

    Question 4: Adding Elements with push()

    What is the result of:

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

    Question 5: Anonymous Functions

    An anonymous function is a function that:

    Question 6: Adding Properties

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

    Question 7: this in Object Method

    What does the following code output?

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

    Question 8: Modifying Text Content

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

    Question 9: Template Literals

    How do you create a string using template literals?

    Question 10: then() Method

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

    Question 11: Type Conversion to Number

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

    Question 12: Logical AND

    What is the result of true && false?

    Question 13: JS While Loop

    What is the output?

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

    Question 14: Removing Last Element

    What is the result of:

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

    Question 15: Function Hoisting

    Which type of function gets hoisted completely in JavaScript?

    Question 16: Object.keys()

    What does Object.keys(obj) return?

    Question 17: this in Arrow Functions

    What is special about this in arrow functions?

    Question 18: Creating Elements

    Which method creates a new HTML element?

    Question 19: Default Parameters

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

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

    Question 20: catch() Method

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