100 JavaScript MCQ Questions and Answers. 100 objective questions on JavaScript basics. Test understanding of syntax, data types, functions, loops & DOM interaction. Answers provided.
100 JavaScript MCQ Questions and Answers – Mock Online Test
Question 1: Which of the following best describes JavaScript?
A. A markup language used to structure web pages
B. A style sheet language used to control the presentation of web pages
C. A scripting language used to add interactivity to web pages
D. A server-side language used to handle database operations
C. A scripting language used to add interactivity to web pages. JavaScript is a scripting language that enables dynamic and interactive elements on websites.
Question 2: Who created JavaScript?
A. Tim Berners-Lee
B. Brendan Eich
C. James Gosling
D. Guido van Rossum
B. Brendan Eich. Brendan Eich created JavaScript while working at Netscape Communications.
Question 3: Which of the following is NOT a common use of JavaScript in web development?
A. Validating user input in forms
B. Creating animations and visual effects
C. Defining the structure and content of a web page
D. Making web pages dynamic and interactive
C. Defining the structure and content of a web page. Defining the structure and content of a web page is primarily done with HTML, not JavaScript.
Question 4: Where does client-side JavaScript code execute?
A. On the user’s web browser
B. On a remote web server
C. In a database
D. In a virtual machine
A. On the user’s web browser. Client-side JavaScript runs within the user’s web browser.
Question 5: What is the relationship between JavaScript and ECMAScript?
A. ECMAScript is a specific implementation of JavaScript.
B. JavaScript is a standardized version of ECMAScript.
C. ECMAScript is the standardized specification that JavaScript is based on.
D. They are completely unrelated languages.
C. ECMAScript is the standardized specification that JavaScript is based on. ECMAScript provides the standards that JavaScript implementations adhere to.
Question 6: Which of the following is NOT a primitive data type in JavaScript?
A. Number
B. String
C. Object
D. Boolean
C. Object. An object is a complex data type, not a primitive one.
Question 7: What is the output of typeof null in JavaScript?
A. “null”
B. “undefined”
C. “object”
D. “symbol”
C. “object”. This is a quirk of JavaScript; typeof null returns “object”.
Question 8: What does the symbol data type represent in JavaScript?
A. A string literal
B. A unique and immutable value
C. An alias for another variable
D. A floating-point number
B. A unique and immutable value. Symbols are primarily used as unique property keys in objects.
Question 9: Which keyword is used to declare a variable with block scope in JavaScript?
A.var
B.let
C.const
D. Both B and C
D. Both B and C. Both let and const declare variables with block scope.
Question 10: What is the difference between let and const in JavaScript?
A.let can be reassigned, while const cannot.
B.const can be reassigned, while let cannot.
C.let is used for strings, while const is used for numbers.
D. They are interchangeable keywords.
A. let can be reassigned, while const cannot. let allows for reassignment of a variable, whereas const creates a read-only variable.
Question 11: What will happen when you try to reassign a const variable?
A. The code will execute without any errors.
B. It will update the value of the variable.
C. It will throw a TypeError.
D. It will create a new variable with the same name.
C. It will throw a TypeError. Reassigning a const variable results in a TypeError.
Question 12: What is type coercion in JavaScript?
A. Explicitly converting one data type to another.
B. Implicitly converting one data type to another.
C. Checking the data type of a variable.
D. Declaring a variable without specifying its type.
B. Implicitly converting one data type to another. Type coercion is JavaScript’s automatic conversion of values from one data type to another.
Question 13: What is the result of the expression 5 + "5" in JavaScript?
A. 10
B. 25
C. “55”
D. “10”
C. “55”. The number 5 is coerced into a string, resulting in string concatenation.
Question 14: Which function can be used to convert a string to a number in JavaScript?
A.toString()
B.parseInt()
C.parseFloat()
D. Both B and C
D. Both B and C. Both parseInt() and parseFloat() convert strings to numbers, with the latter handling decimals.
Question 15: What does the modulus operator (%) do in JavaScript?
A. Divides two numbers and returns the quotient.
B. Divides two numbers and returns the remainder.
C. Raises a number to a specified power.
D. Calculates the square root of a number.
B. Divides two numbers and returns the remainder. The modulus operator gives the remainder after division.
Question 16: What is the result of the expression 10 < 5 || 5 > 2?
A. true
B. false
C. undefined
D. null
A. true. The expression evaluates to true because 5 > 2 is true, and the || operator only needs one condition to be true.
Question 17: Which operator is used to assign a value to a variable in JavaScript?
A.==
B.===
C.=
D.+
C. =. The single equals sign (=) is the assignment operator.
Question 18: What does the strict equality operator (===) check for in JavaScript?
A. Only value equality
B. Only type equality
C. Both value and type equality
D. Neither value nor type equality
C. Both value and type equality. The strict equality operator ensures that both the value and the data type are the same.
Question 19: What is the difference between == and === in JavaScript?
A.== performs type coercion, while === does not.
B.=== performs type coercion, while == does not.
C.== checks for strict equality, while === checks for loose equality.
D. They are interchangeable operators.
A. == performs type coercion, while === does not. The double equals (==) allows for type coercion, while the triple equals (===) requires the types to be the same.
Question 20: In the expression 5 + 4 * 2, which operation is performed first?
A. Addition
B. Multiplication
C. They are performed from left to right.
D. It depends on the JavaScript engine.
B. Multiplication. Multiplication has higher precedence than addition.
Question 21: What does operator associativity determine in JavaScript?
A. The order of operations when operators have the same precedence
B. The data type of the result of an expression
C. Whether type coercion will occur
D. The scope of a variable
A. The order of operations when operators have the same precedence. Associativity defines the direction of operation when operators have equal precedence.
Question 22: What is the purpose of the conditional (ternary) operator in JavaScript?
A. To create a loop that iterates a specific number of times
B. To define a function that can be called later
C. To provide a shorthand way to write an if-else statement
D. To handle potential errors in code
C. To provide a shorthand way to write an if-else statement. The ternary operator offers a concise way to express conditional logic.
Question 23: What is a string literal in JavaScript?
A. A variable that stores a string value
B. A sequence of characters enclosed in single or double quotes
C. A method used to manipulate strings
D. A special character used to escape other characters
B. A sequence of characters enclosed in single or double quotes. String literals are how you represent text within your code.
Question 24: Which property of a string returns its length in JavaScript?
A.size
B.length
C.count
D.index
B. length. The length property provides the number of characters in a string.
Question 25: What does the toUpperCase() method do to a string in JavaScript?
A. Converts the string to lowercase
B. Converts the string to uppercase
C. Removes whitespace from the beginning and end of the string
D. Reverses the order of characters in the string
B. Converts the string to uppercase. toUpperCase() transforms all characters in a string to uppercase.
Question 26: How do you concatenate two strings in JavaScript?
A. Using the + operator
B. Using the concat() method
C. Both A and B
D. Using the join() method
C. Both A and B. You can concatenate strings with either the + operator or the concat() method.
Question 27: Which method is used to extract a portion of a string in JavaScript?
A.substring()
B.slice()
C.substr()
D. All of the above
D. All of the above. All three methods (substring(), slice(), and substr()) can be used to extract parts of a string, each with slightly different behaviors.
Question 28: What is the value of NaN in JavaScript?
A. A specific number
B. A string representing “Not a Number”
C. A special value indicating an invalid number operation
D. The largest possible number in JavaScript
C. A special value indicating an invalid number operation. NaN signifies that a mathematical operation did not result in a meaningful number.
Question 29: Which method is used to round a number to the nearest integer in JavaScript?
A.Math.floor()
B.Math.ceil()
C.Math.round()
D.Math.trunc()
C. Math.round(). Math.round() rounds a number to the nearest integer.
Question 30: What are the two possible values of a boolean in JavaScript?
A. 0 and 1
B. “true” and “false”
C. true and false
D. yes and no
C. true and false. Booleans hold either true or false.
Question 31: What is a “truthy” value in JavaScript?
A. A value that is strictly equal to true
B. Any value that evaluates to true in a boolean context
C. A string that contains the word “true”
D. A non-zero number
B. Any value that evaluates to true in a boolean context. Truthy values are treated as true in conditions.
Question 32: Which of the following is a “falsy” value in JavaScript?
A. 0
B. An empty string (“”)
C.null
D. All of the above
D. All of the above. All listed values are considered falsy in JavaScript.
Question 33: How do you create an empty array in JavaScript?
A.var myArray = [];
B.var myArray = new Array();
C. Both A and B
D.var myArray = {};
C. Both A and B.
Question 34: Which index represents the first element in a JavaScript array?
A. 1
B. 0
C. -1
D. Any number
B. 0. JavaScript arrays are zero-indexed.
Question 35: What does the push() method do to an array in JavaScript?
A. Adds an element to the beginning of the array
B. Adds an element to the end of the array
C. Removes an element from the beginning of the array
D. Removes an element from the end of the array
B. Adds an element to the end of the array. push() appends an element to the end.
Question 36: What does the pop() method do to an array?
A. Adds an element to the beginning of the array.
B. Adds an element to the end of the array.
C. Removes the first element from the array.
D. Removes the last element from the array.
D. Removes the last element from the array. pop() removes and returns the last element.
Question 37: Which array method is used to add an element to the beginning of an array?
A.push()
B.unshift()
C.shift()
D.splice()
B. unshift(). unshift() adds elements to the front of an array.
Question 38: What does the splice() method allow you to do with an array?
A. Add or remove elements at any position
B. Sort the elements of the array
C. Reverse the order of elements in the array
D. Create a copy of the array
A. Add or remove elements at any position. splice() is versatile for adding and removing elements at specific indices.
Question 39: Which loop is specifically designed for iterating over the properties of an object in JavaScript?
A.for loop
B.for...in loop
C.for...of loop
D.while loop
B. for...in loop. The for...in loop is used to loop through the keys of an object.
Question 40: What does the forEach() method do in JavaScript?
A. Executes a provided function once for each array element
B. Creates a new array with the results of calling a function on every element
C. Filters the array based on a condition
D. Sorts the array in ascending order
A. Executes a provided function once for each array element. forEach() iterates over array elements and applies a function to each.
Question 41: How do you create an empty object in JavaScript?
A.var myObject = {};
B.var myObject = new Object();
C. Both A and B
D.var myObject = [];
C. Both A and B. Both the object literal ({}) and the Object() constructor create objects.
Question 42: What is the purpose of the this keyword within an object in JavaScript?
A. It refers to the current object.
B. It refers to the parent object.
C. It refers to the global object.
D. It refers to the previous object.
A. It refers to the current object. this provides a way to access properties and methods within the object itself.
Question 43: What are the two ways to access properties of an object in JavaScript?
A. Dot notation and bracket notation
B. Parentheses and curly braces
C. Single quotes and double quotes
D. Forward slashes and backslashes
A. Dot notation and bracket notation.
Question 44: What does an if statement do in JavaScript?
A. Executes a block of code only if a specified condition is true
B. Executes a block of code repeatedly
C. Defines a function that can be called later
D. Handles potential errors in code
A. Executes a block of code only if a specified condition is true. if statements control code execution based on a condition.
Question 45: What is the purpose of the else clause in an if-else statement?
A. To specify an alternative block of code to execute if the if condition is true
B. To specify a block of code to execute if the if condition is false
C. To define a loop that iterates a specific number of times
D. To handle potential errors in code
B. To specify a block of code to execute if the if condition is false. The else block provides an alternative path when the if condition isn’t met.
Question 46: When is the code inside an else if block executed?
A. Always
B. Only if the preceding if condition is true
C. Only if the preceding if condition is false and the else if condition is true
D. Only if the preceding if and all preceding else if conditions are false
C. Only if the preceding if condition is false and the else if condition is true. else if provides additional conditional checks when the previous if is false.
Question 47: What is the purpose of a switch statement in JavaScript?
A. To create a loop that iterates a specific number of times
B. To provide an alternative to using multiple if-else if statements
C. To define a function that can be called later
D. To handle potential errors in code
B. To provide an alternative to using multiple if-else if statements. switch statements offer a cleaner way to handle multiple possible values of a variable.
Question 48: What does the break keyword do within a switch statement?
A. Exits the entire switch statement
B. Skips to the next case in the switch statement
C. Continues to the next iteration of the loop
D. Throws an error
A. Exits the entire switch statement. break ensures that only the matching case’s code is executed.
Question 49: What happens if you omit the break keyword in a switch statement?
A. The code execution stops at the matching case.
B. The code execution continues to the next case, even if it doesn’t match.
C. An error is thrown.
D. The switch statement is ignored.
B. The code execution continues to the next case, even if it doesn’t match. Without break, execution “falls through” to subsequent cases.
Question 50: What is the purpose of a for loop in JavaScript?
A. To execute a block of code repeatedly for a specific number of times
B. To execute a block of code only if a specified condition is true
C. To define a function that can be called later
D. To handle potential errors in code
A. To execute a block of code repeatedly for a specific number of times. for loops are designed for repeated execution based on a counter.
Question 51: Which loop in JavaScript executes a block of code as long as a specified condition is true?
A.for loop
B.while loop
C.do...while loop
D.for...of loop
B. while loop. A while loop continues as long as its condition remains true.
Question 52: What is the key difference between a while loop and a do...while loop?
A. A while loop checks the condition before executing the code block, while a do...while loop checks it after.
B. A do...while loop checks the condition before executing the code block, while a while loop checks it after.
C. A while loop is used for iterating over arrays, while a do...while loop is used for iterating over objects.
D. They are functionally identical.
A. A while loop checks the condition before executing the code block, while a do...while loop checks it after. A do...while loop guarantees at least one execution of its code block.
Question 53: Which loop is best suited for iterating over the elements of an array in JavaScript?
A.for loop
B.for...in loop
C.for...of loop
D.while loop
C. for...of loop. The for...of loop provides a clean way to iterate through array values.
Question 54: What does the break statement do within a loop?
A. Exits the current iteration of the loop and continues with the next iteration
B. Exits the entire loop immediately
C. Skips to the next iteration of the loop
D. Throws an error
B. Exits the entire loop immediately. break terminates the loop entirely.
Question 55: What does the continue statement do within a loop?
A. Exits the entire loop immediately
B. Skips the rest of the current iteration and continues with the next iteration
C. Pauses the loop execution
D. Throws an error
B. Skips the rest of the current iteration and continues with the next iteration. continue jumps to the next loop iteration.
Question 56: What is a function in JavaScript?
A. A block of code that can be reused multiple times
B. A variable that stores a value
C. A data type that represents a true or false value
D. An error that occurs during code execution
A. A block of code that can be reused multiple times. Functions encapsulate reusable blocks of code.
Question 57: What keyword is used to define a function in JavaScript?
A.func
B.function
C.define
D.method
B. function. The function keyword starts a function declaration.
Question 58: What are function parameters?
A. Values passed to a function when it is called
B. Values returned by a function
C. Variables declared inside a function
D. Errors that can occur within a function
A. Values passed to a function when it is called. Parameters act as placeholders for values that a function will receive.
Question 59: What is the purpose of the return statement in a function?
A. To specify the parameters of the function
B. To define the code block of the function
C. To specify the value that the function should return
D. To call another function
C. To specify the value that the function should return. return sends a value back from the function.
Question 60: What is function scope in JavaScript?
A. The area of code where a function can be called
B. The accessibility of variables within and outside a function
C. The data type of the value returned by a function
D. The number of parameters a function can accept
B. The accessibility of variables within and outside a function. Scope determines which variables a function can access.
Question 61: What is an arrow function in JavaScript?
A. A shorthand way to write functions
B. A function that can only be called once
C. A function that always returns a boolean value
D. A function that throws an error
A. A shorthand way to write functions. Arrow functions provide a more concise syntax for function expressions.
Question 62: What is one key difference between regular functions and arrow functions in terms of the this keyword?
A. Arrow functions have their own this binding, while regular functions do not.
B. Regular functions have their own this binding, while arrow functions do not.
C. Arrow functions cannot use the this keywor
D. D. They are identical in how they handle this.
B. Regular functions have their own this binding, while arrow functions do not. Arrow functions inherit this from their surrounding context.
Question 63: What is the purpose of a try...catch statement in JavaScript?
A. To define a loop that iterates a specific number of times
B. To handle potential errors that may occur in a block of code
C. To define a function that can be called later
D. To create a conditional statement
B. To handle potential errors that may occur in a block of code. try...catch allows you to gracefully manage runtime errors.
Question 64: What does the throw statement do in JavaScript?
A. Catches an error
B. Generates a custom error
C. Ignores an error
D. Prevents an error from occurring
B. Generates a custom error. throw creates an exception that can be caught.
Question 65: What does DOM stand for in web development?
A. Data Object Model
B. Document Object Model
C. Digital Order Management
D. Dynamic Output Mechanism
B. Document Object Model. The DOM is a tree-like representation of an HTML document.
Question 66: What are nodes in the DOM?
A. Programming languages used to create web pages
B. Individual elements, attributes, and text within an HTML document
C. Styles applied to elements in a web page
D. Events that can occur on a web page
B. Individual elements, attributes, and text within an HTML document. Nodes are the fundamental building blocks of the DOM tree.
Question 67: Which method is used to select an element by its ID in JavaScript?
A.getElementById()
B.getElementsByTagName()
C.getElementsByClassName()
D.querySelector()
A. getElementById(). getElementById() retrieves a single element with a specific ID.
Question 68: What does getElementsByTagName() return in JavaScript?
A. A single element with the specified tag name
B. A live HTMLCollection of elements with the specified tag name
C. A static NodeList of elements with the specified tag name
D. An array of elements with the specified tag name
B. A live HTMLCollection of elements with the specified tag name. getElementsByTagName() gives you a live collection of elements.
Question 69: How does querySelector() differ from querySelectorAll()?
A.querySelector() returns a NodeList, while querySelectorAll() returns a single element.
B.querySelectorAll() returns a NodeList, while querySelector() returns a single element.
C.querySelector() only works with IDs, while querySelectorAll() works with any CSS selector.
D. They are interchangeable methods.
B. querySelectorAll() returns a NodeList, while querySelector() returns a single element. querySelector() gets the first matching element, while querySelectorAll() gets all of them.
Question 70: Which property is used to change the text content of an element in JavaScript?
A.innerHTML
B.textContent
C. Both A and B
D.value
C. Both A and B. Both innerHTML (which can include HTML tags) and textContent (plain text only) can modify element content.
Question 71: Which method is used to set an attribute of an element in JavaScript?
A.setAttribute()
B.getAttribute()
C.removeAttribute()
D.hasAttribute()
A. setAttribute(). setAttribute() updates or adds an attribute to an element.
Question 72: How can you change the style of an element using JavaScript?
A. By modifying the style property of the element
B. By applying a CSS class to the element
C. Both A and B
D. By using the setStyle() method
C. Both A and B. You can directly manipulate the style object or add/remove CSS classes.
Question 73: Which method is used to create a new HTML element in JavaScript?
A.createElement()
B.addNewElement()
C.createNode()
D.insertElement()
A. createElement(). createElement() generates a DOM element that you can then insert.
Question 74: What does the appendChild() method do in JavaScript?
A. Adds a new child node to the beginning of a parent node
B. Adds a new child node to the end of a parent node
C. Removes a child node from a parent node
D. Replaces a child node with another node
B. Adds a new child node to the end of a parent node. appendChild() inserts a node as the last child of an element.
Question 75: What is an event listener in JavaScript?
A. A function that waits for a specific event to occur on an element
B. An attribute that defines the type of event an element can handle
C. A method that triggers an event on an element
D. An object that stores information about an event
A. A function that waits for a specific event to occur on an element. Event listeners are set up to react to user interactions or other occurrences.
Question 76: Which method is used to attach an event listener to an element?
A.addEventListener()
B.attachEvent()
C.onEvent()
D.listenForEvent()
A. addEventListener(). addEventListener() is the standard way to register event handlers.
Question 77: Which of the following is NOT a common event type in JavaScript?
A.click
B.mouseover
C.submit
D.resize
D. resize. While resize is an event, it’s related to the window, not a typical element event like the others.
Question 78: What is event bubbling in JavaScript?
A. The order in which event handlers are executed when an event occurs on an element with nested child elements
B. The process of preventing an event from being handled by its default handler
C. The act of triggering an event programmatically
D. The way events are passed from child elements to their parent elements
D. The way events are passed from child elements to their parent elements. Event bubbling describes how an event propagates up the DOM tree from the target element to its ancestors.
Question 79: What is the purpose of the event object in an event handler function?
A. To store information about the event that occurred
B. To prevent the default behavior of the event
C. To stop the event from bubbling up the DOM tree
D. To create a new event
A. To store information about the event that occurred. The event object provides details like the event type, target element, and mouse coordinates.
Question 80: What is a prototype in JavaScript?
A. A blueprint for creating objects
B. An object that serves as a template for other objects
C. A property that defines the data type of an object
D. A method that is inherited by all objects
B. An object that serves as a template for other objects. Prototypes provide a mechanism for inheritance in JavaScript.
Question 81: What is the purpose of the class keyword in JavaScript?
A. To declare a variable
B. To define a function
C. To create a blueprint for objects
D. To handle errors
C. To create a blueprint for objects. The class keyword provides a more structured way to define object blueprints (constructors) and their associated methods.
Question 82: What is a constructor in JavaScript?
A. A special method that is called when an object is created from a class
B. A property that defines the data type of an object
C. A loop that iterates over the properties of an object
D. A function that is inherited by all objects
A. A special method that is called when an object is created from a class. Constructors initialize the properties of newly created objects.
Question 83: What is encapsulation in object-oriented programming?
A. The process of combining data and methods that operate on that data within a single unit (the object)
B. The ability of an object to take on many forms
C. The mechanism by which objects inherit properties and methods from their parent objects
D. The practice of writing code that is easy to read and understand
A. The process of combining data and methods that operate on that data within a single unit (the object). Encapsulation bundles data and methods, promoting organization and modularity.
Question 84: What is inheritance in object-oriented programming?
A. The process of creating new objects from a blueprint
B. The ability of objects to share behaviors and characteristics from other objects
C. The act of hiding data within an object
D. The practice of writing code that can handle errors gracefully
B. The ability of objects to share behaviors and characteristics from other objects. Inheritance allows objects to inherit properties and methods, reducing code duplication.
Question 85: What is polymorphism in object-oriented programming?
A. The ability of objects to take on many forms
B. The process of creating new objects from a blueprint
C. The act of hiding data within an object
D. The practice of writing code that can handle errors gracefully
A. The ability of objects to take on many forms. Polymorphism allows objects of different classes to be treated as objects of a common type.
Question 86: What is a callback function in JavaScript?
A. A function that is passed as an argument to another function and is executed after the first function completes
B. A function that is called immediately
C. A function that is defined within another function
D. A function that throws an error
A. A function that is passed as an argument to another function and is executed after the first function completes. Callbacks are a way to handle operations that take time to complete, like network requests.
Question 87: What is a Promise in JavaScript?
A. A variable that stores a value
B. An object that represents the eventual result of an asynchronous operation
C. A function that is called repeatedly
D. An error that occurs during code execution
B. An object that represents the eventual result of an asynchronous operation. Promises provide a more structured way to handle asynchronous tasks than callbacks.
Question 88: What are the three possible states of a Promise?
A. Pending, Fulfilled, Rejected
B. Open, Closed, Error
C. True, False, Null
D. Start, Running, Finished
A. Pending, Fulfilled, Rejected. A Promise can be pending (ongoing), fulfilled (successful), or rejected (failed).
Question 89: What is the purpose of the async and await keywords in JavaScript?
A. To define synchronous functions
B. To handle errors in asynchronous code
C. To simplify working with Promises
D. To create loops
C. To simplify working with Promises. async/await makes asynchronous code look and behave a bit more like synchronous code.
Question 90: What is JSON?
A. A programming language
B. A lightweight data interchange format
C. A type of database
D. A JavaScript framework
B. A lightweight data interchange format. JSON is a text-based format for representing data as key-value pairs.
Question 91: Which method is used to convert a JavaScript object into a JSON string?
A.JSON.parse()
B.JSON.stringify()
C.Object.toJSON()
D.String.fromObject()
B. JSON.stringify(). JSON.stringify() serializes a JavaScript object into JSON format.
Question 92: What is a regular expression in JavaScript?
A. A pattern used to match character combinations in strings
B. A variable that stores a string value
C. A method used to manipulate strings
D. A special character used to escape other characters
A. A pattern used to match character combinations in strings. Regular expressions are powerful tools for text processing and validation.
Question 93: What is the purpose of the test() method in a regular expression?
A. To replace all occurrences of a pattern in a string
B. To extract the portion of a string that matches a pattern
C. To check if a string matches a pattern
D. To create a new regular expression
C. To check if a string matches a pattern. The test() method checks for matches between a regular expression and a string.
Question 94: What is a module in JavaScript?
A. A reusable block of code that can be imported into other files
B. A variable that stores a value
C. A data type that represents a true or false value
D. An error that occurs during code execution
A. A reusable block of code that can be imported into other files. Modules help organize code and promote reusability.
Question 95: What is the Browser Object Model (BOM)?
A. A tree-like representation of an HTML document
B. A programming interface for interacting with the web browser
C. A set of standards for web development
D. A JavaScript framework
B. A programming interface for interacting with the web browser. The BOM provides objects for controlling browser features like the history and window.
Question 96: Which object in the BOM represents the current browser window?
A.document
B.window
C.navigator
D.history
B. window. The window object is the top-level object in the BOM.
Question 97: Which object in the BOM provides information about the user’s browser?
A.document
B.window
C.navigator
D.history
C. navigator. The navigator object gives details about the browser itself.
Question 98: Which event is triggered when a user clicks a mouse button?
A.mousedown
B.mouseup
C.click
D. All of the above
D. All of the above. All three events are related to mouse clicks, but click represents a complete click action.
Question 99: Which event is triggered when a user moves the mouse over an element?
A.mousemove
B.mouseover
C.mouseout
D.mouseenter
B. mouseover. mouseover fires when the mouse enters the area of an element.
Question 100: Which function is used to execute a block of code after a specified delay in milliseconds?
A.setTimeout()
B.setInterval()
C.delay()
D.pause()
A. setTimeout(). setTimeout() schedules a function to run once after a given delay.
pls ma’am provide the question , according to CITS course trade CSA
and some important topic name as a networking, php, python , java , javascript, DBMS, Advance Exvel .
pls provide mcq in this topic .
pls ma’am provide the question , according to CITS course trade CSA
and some important topic name as a networking, php, python , java , javascript, DBMS, Advance Exvel .
pls provide mcq in this topic .