Explanation:Checkboxes have a 'checked' boolean property indicating their state.
Incorrect! Try again.
33Can a JavaScript function return another function?
A.No, never
B.Yes, this is called a closure or higher-order function
C.Only in strict mode
D.Only if it returns a string
Correct Answer: Yes, this is called a closure or higher-order function
Explanation:JavaScript functions are first-class citizens and can return other functions.
Incorrect! Try again.
34Which mouse event is fired when a mouse button is pressed down (before releasing)?
A.onmouseup
B.onclick
C.onmousedown
D.onmousepress
Correct Answer: onmousedown
Explanation:The 'onmousedown' event occurs when a mouse button is pressed down over an element.
Incorrect! Try again.
35To validate that a password is at least 8 characters long, which condition is used?
A.password.value.size >= 8
B.password.value.length >= 8
C.password.length >= 8
D.password.val.len >= 8
Correct Answer: password.value.length >= 8
Explanation:You must access the '.value' of the input first, then the '.length' property of that string.
Incorrect! Try again.
36What defines the scope of a variable declared with 'var' inside a function?
A.Global scope
B.Function scope
C.Block scope
D.Document scope
Correct Answer: Function scope
Explanation:Variables declared with 'var' inside a function are local to that function (Function Scope).
Incorrect! Try again.
37Which of the following is an anonymous function?
A.function myFunc() {}
B.var myFunc = function() {}
C.function() {}
D.Both B and C
Correct Answer: Both B and C
Explanation:An anonymous function is a function without a name. It can be used in an expression or assigned to a variable.
Incorrect! Try again.
38Which regex syntax is used to create a Regular Expression object?
A./pattern/flags
B.new RegExp('pattern', 'flags')
C.Both A and B
D.RegExp(/pattern/)
Correct Answer: Both A and B
Explanation:Regular expressions can be created using literal syntax (/.../) or the RegExp constructor.
Incorrect! Try again.
39In a dropdown list (select tag), how do you get the index of the selected option?
A.element.value
B.element.selectedIndex
C.element.optionIndex
D.element.choice
Correct Answer: element.selectedIndex
Explanation:The 'selectedIndex' property sets or returns the index of the selected option in a drop-down list.
Incorrect! Try again.
40What is the default return value of a function that does not have a return statement?
A.null
B.
C.undefined
D.void
Correct Answer: undefined
Explanation:If a function does not return a value, it returns 'undefined' by default.
Incorrect! Try again.
41Which event is commonly used to detect if a user is typing inside a text box?
A.onselect
B.onkeyup
C.onclick
D.onload
Correct Answer: onkeyup
Explanation:onkeyup (or oninput) is commonly used to trigger code as the user types.
Incorrect! Try again.
42How can you stop a function execution if a validation error occurs?
A.break
B.stop
C.return false
D.exit
Correct Answer: return false
Explanation:Returning 'false' is the standard way to indicate failure in a validation function and stop subsequent logic (often used to stop form submission).
Incorrect! Try again.
43Which JavaScript function displays a dialog box with a message and an OK button?
A.prompt()
B.confirm()
C.alert()
D.msg()
Correct Answer: alert()
Explanation:The alert() method displays an alert box with a specified message and an OK button.
Incorrect! Try again.
44To check if a radio button is selected, which property do we check?
A.selected
B.toggled
C.checked
D.active
Correct Answer: checked
Explanation:Radio buttons, like checkboxes, use the 'checked' property.
Incorrect! Try again.
45When handling the 'onkeypress' event, how can you allow only numbers to be entered?
A.Check if event.keyCode is between 48 and 57
B.Check if event.key is 'Number'
C.Use type='text'
D.Disable the keyboard
Correct Answer: Check if event.keyCode is between 48 and 57
Explanation:ASCII codes 48 to 57 correspond to digits 0-9. Checking keyCode allows blocking non-numeric input.
Incorrect! Try again.
46Which is the correct syntax to bind an event handler in HTML?
A.<button event='myFunc()'>
B.<button onclick='myFunc()'>
C.<button click='myFunc()'>
D.<button do='myFunc()'>
Correct Answer: <button onclick='myFunc()'>
Explanation:The standard HTML attribute syntax for a click event is onclick='...'.
Incorrect! Try again.
47What is passed to the event handler function if defined as 'element.onclick = myFunction;'?
A.Nothing
B.The Event object
C.The element
D.The document
Correct Answer: The Event object
Explanation:When assigning a function to an event property in JS, the browser automatically passes the event object as the first argument.
Incorrect! Try again.
48Which function converts a string argument to an integer?
A.toInteger()
B.parseInt()
C.Float()
D.NumberString()
Correct Answer: parseInt()
Explanation:The parseInt() function parses a string argument and returns an integer.
Incorrect! Try again.
49In validation, if a field is empty, what does 'field.value' equal?
A.null
B.undefined
C."" (empty string)
D.
Correct Answer: "" (empty string)
Explanation:An empty HTML input field returns an empty string ("") via the .value property.
Incorrect! Try again.
50What is the order of mouse events when clicking a button?