Here are Top 100 multiple-choice questions (MCQs) focused on the HTML5 features and elements in JavaScript MCQs, along with their answers and explanations.

PRACTICE IT NOW TO SHARPEN YOUR CONCEPT AND KNOWLEDGE

view hide answers

1. What is the purpose of a JavaScript variable?

  • To store and manage data
  • To define functions
  • To control the flow of execution
  • To create HTML elements

2. Which keyword is used to declare a variable in JavaScript?

  • let
  • var
  • const
  • variable

3. What is the difference between let and const for variable declaration?

  • let allows reassignment, while const does not.
  • const allows reassignment, while let does not.
  • let and const are interchangeable.
  • Both let and const prevent variable declaration.

4. What is the value of a variable that is declared but not initialized?

  • 0
  • null
  • undefined
  • false

5. Which data type is used to represent whole numbers in JavaScript?

  • Integer
  • Float
  • String
  • Number

6. What is the result of the expression 5 + '5' in JavaScript?

  • 10
  • 55
  • '55'
  • Error

7. What is the purpose of the typeof operator in JavaScript?

  • To perform type conversion
  • To check if a variable is undefined
  • To convert a variable to a number
  • To determine the data type of a value

8. Which operator is used to compare two values for equality without considering their data types?

  • '=='
  • '==='
  • '!='
  • '!=='

9. Which operator is used to compare two values for equality while also checking their data types?

  • '=='
  • '==='
  • '!='
  • '!=='

10. What does the '&&' operator do in JavaScript?

  • It performs a logical OR operation
  • It performs a logical NOT operation
  • It performs a logical AND operation
  • It concatenates strings

11. Which operator is used to increment a variable in JavaScript?

  • '++'
  • '--'
  • '+='
  • '-='

12. What is the purpose of the typeof operator in JavaScript?

  • To convert a value to a different data type
  • To check the type of a value
  • To perform arithmetic operations
  • To create a new variable

13. What is the purpose of the '!'operator in JavaScript?

  • It performs addition
  • It negates a Boolean value
  • It concatenates strings
  • It multiplies numbers

14. What is the result of the expression 5 + 2 * 3 in JavaScript?

  • 15
  • 11
  • 20
  • 9

15. How do you define a multi-line comment in JavaScript?

  • '// This is a comment'
  • <!-- This is a comment -->
  • '/* This is a comment */'
  • '#' This is a comment

16. What is the result of the expression 5 % 2 in JavaScript?

  • 5
  • 2.5
  • 1
  • 0

17. Which operator is used to concatenate strings in JavaScript?

  • '+'
  • '&'
  • '+'
  • '.'

18. What does the NaN value represent in JavaScript?

  • An empty string
  • A missing or non-existent value
  • A zero value
  • A special value representing "Not-a-Number"

19. What is the result of the expression 5 == '5' in JavaScript?

  • true
  • false
  • Error
  • Undefined

20. How do you declare a constant variable in JavaScript?

  • const myVar
  • let myVar
  • var myVar
  • constant myVar

21. What is the purpose of the Math.random() function in JavaScript?

  • To generate random numbers
  • To perform mathematical calculations
  • To round numbers to the nearest integer
  • To check if a variable is defined

22. What is the value of null in JavaScript?

  • A missing or non-existent value
  • Zero
  • An empty string
  • False

23. What is the result of the expression '5' - 2 in JavaScript?

  • '3'
  • 3
  • Error
  • NaN

24. Which logical operator is used to perform a logical OR operation in JavaScript?

  • '&&'
  • '||'
  • '!'
  • '=='

25. What is the purpose of the typeof operator in JavaScript?

  • To create a new object
  • To change the type of a variable
  • To define functions
  • To determine the data type of a value

26. What is the result of the expression '5' + 2 in JavaScript?

  • '7'
  • 7
  • Error
  • 52

27. What is the purpose of the parseInt() function in JavaScript?

  • To convert a string to an integer
  • To round a number to the nearest integer
  • To calculate the square root of a number
  • To create a new variable

28. What is the JavaScript operator for exponentiation (raising a number to a power)?

  • '^'
  • '**'
  • '*'
  • '%'

29. Which operator is used to concatenate two or more arrays in JavaScript?

  • +
  • concat()
  • merge()
  • extend()

30. What is the value of typeof null in JavaScript?

  • Object
  • Null
  • Undefined
  • NullObject

31. What is the result of the expression 'Hello'.length in JavaScript?

  • Error
  • Undefined
  • 5
  • 'Hello'

32. Which built-in object in JavaScript represents a date and time?

  • TimeObject
  • Clock
  • Date
  • DateTime

33. What is the result of the expression 5 > 3 && 2 < 4 in JavaScript?

  • true
  • false
  • Error
  • Undefined

34. What is the result of the expression '5' '===' 5 in JavaScript?

  • true
  • false
  • Error
  • Undefined

35. What is the result of the expression NaN '===' NaN in JavaScript?

  • true
  • false
  • Error
  • Undefined

36. Which operator is used to access properties of an object in JavaScript?

  • '.'
  • '.'
  • '[]'
  • '()'

37. What is the result of the expression 5 / 0 in JavaScript?

  • 5
  • 0
  • Infinity
  • Error

38. Which operator is used for assigning a value to a variable in JavaScript?

  • '='
  • '=='
  • '==='
  • '.'

39. What is the result of the expression null '==' undefined in JavaScript?

  • true
  • false
  • Error
  • Undefined

40. What is the JavaScript operator for the remainder of a division operation?

  • '%'
  • '//'
  • '/'
  • '*'

41. What is the purpose of the Math.floor() function in JavaScript?

  • To round a number up to the nearest integer
  • To round a number to the nearest integer
  • To return the largest integer less than or equal to a given number
  • To perform mathematical operations

42. What is the result of the expression '5' - '2' in JavaScript?

  • 3
  • '3'
  • Error
  • NaN

43. What is the JavaScript operator for the logical NOT operation?

  • '!'
  • '&&'
  • '||'
  • '='

44. What is the result of the expression true '&&' false in JavaScript?

  • true
  • false
  • Error
  • Undefined

45. What is the result of the expression '5' * 2 in JavaScript?

  • 10
  • '10'
  • Error
  • 52

46. Which operator is used to compare two values for inequality without considering their data types?

  • '!='
  • '/='
  • <>
  • '!=='

47. What is the result of the expression '5' + true in JavaScript?

  • 'true5'
  • '6'
  • 6
  • Error

48. What is the result of the expression null + 5 in JavaScript?

  • 5
  • 0
  • 'null5'
  • Error

49. What does the toFixed() function do in JavaScript?

  • It converts a number to a string
  • It rounds a number to a specified number of decimal places
  • It calculates the square root of a number
  • It checks if a variable is defined

50. What is the JavaScript operator for the remainder of a division operation?

  • '//'
  • div
  • mod
  • '%'

51. What is the result of the expression 5 * '2' in JavaScript?

  • 10
  • '10'
  • Error
  • 52

52. What does the isNaN() function do in JavaScript?

  • It checks if a value is not a number
  • It converts a value to a number
  • It rounds a number to the nearest integer
  • It checks if a variable is defined

53. What is the result of the expression '5' == true in JavaScript?

  • true
  • false
  • Error
  • Undefined

54. Which built-in object in JavaScript represents the global context?

  • Window
  • Document
  • Global
  • Context

55. What is the purpose of the Math.ceil() function in JavaScript?

  • To round a number up to the nearest integer
  • To round a number to the nearest integer
  • To return the smallest integer greater than or equal to a given number
  • To calculate the square root of a number

56. What is the JavaScript operator for the logical OR operation?

  • '!'
  • '&&'
  • '||'
  • '|'

57. What is the result of the expression 5 + null in JavaScript?

  • 5
  • null
  • Error
  • Undefined

58. Which operator is used to check if a value is less than or equal to another value in JavaScript?

  • <
  • >
  • <=
  • >=

59. What is the result of the expression true '||' false in JavaScript?

  • true
  • false
  • Error
  • Undefined

60. What is the result of the expression '5' - 2 in JavaScript?

  • '3'
  • 3
  • Error
  • NaN

61. What is the purpose of the Math.sqrt() function in JavaScript?

  • To calculate the square root of a number
  • To round a number up to the nearest integer
  • To round a number to the nearest integer
  • To convert a value to a string

62. Which operator is used to check if a value is greater than another value in JavaScript?

  • <
  • >
  • <=
  • >=

63. What is the result of the expression true && true in JavaScript?

  • true
  • false
  • Error
  • Undefined

64. What is the result of the expression '5' + null in JavaScript?

  • '5null'
  • 5
  • 'null'
  • Error

65. What is the JavaScript operator for the logical XOR operation (exclusive or)?

  • '^^'
  • '||'
  • '&&'
  • '^'

66. What is the result of the expression '5' + '2' in JavaScript?

  • 7
  • '72'
  • Error
  • '5' + '2'

67. Which function is used to convert a string to uppercase in JavaScript?

  • toLowerCase()
  • Uppercase()
  • toUpperCase()
  • upper()

68. What is the JavaScript operator for the logical NOT equal operation?

  • '!='
  • '=='
  • '==='
  • '!=='

69. What is the result of the expression 5 / 'two' in JavaScript?

  • 5
  • '5'
  • Error
  • NaN

70. Which operator is used to check if a value is equal to another value without considering their data types?

  • '=='
  • '==='
  • '!='
  • '!=='

71. What is the result of the expression '5' - 'two' in JavaScript?

  • '3'
  • 3
  • Error
  • NaN

72. Which operator is used to access array elements in JavaScript?

  • '[]'
  • '{}'
  • '()'
  • '.'

73. What is the result of the expression undefined + 5 in JavaScript?

  • 5
  • undefined
  • Error
  • NaN

74. What is the purpose of the Math.round() function in JavaScript?

  • To round a number up to the nearest integer
  • To round a number to the nearest integer
  • To calculate the square root of a number
  • To perform mathematical operations

75. What is the result of the expression 5 > 2 '||' 3 > 1 in JavaScript?

  • true
  • false
  • Error
  • Undefined

76. What is the result of the expression true '&&' 0 in JavaScript?

  • true
  • false
  • 0
  • Error

77. What is the JavaScript operator for the bitwise AND operation?

  • '&'
  • '&&'
  • '|'
  • '!'

78. What is the result of the expression '5' '*' 'two' in JavaScript?

  • '52'
  • 52
  • Error
  • NaN

79. What is the result of the expression 5 == '5' in JavaScript?

  • true
  • false
  • Error
  • Undefined

80. What is the JavaScript operator for the bitwise OR operation?

  • '|'
  • '&'
  • '||'
  • '!'

81. What is the purpose of the Math.abs() function in JavaScript?

  • To perform mathematical operations
  • To return the absolute value of a number
  • To calculate the square root of a number
  • To round a number to the nearest integer

82. What is the result of the expression '5' > '10' in JavaScript?

  • true
  • false
  • Error
  • Undefined

83. Which operator is used to perform a bitwise shift to the left in JavaScript?

  • <<
  • >>
  • <<<
  • >>

84. What is the result of the expression 'true' '===' true in JavaScript?

  • true
  • false
  • Error
  • Undefined

85. What is the purpose of the Math.max() function in JavaScript?

  • To return the maximum of two or more numbers
  • To calculate the square root of a number
  • To perform mathematical operations
  • To round a number to the nearest integer

86. What is the JavaScript operator for the bitwise XOR operation?

  • '^'
  • '&'
  • '|'
  • '!'

87. What is the result of the expression true '&&' true in JavaScript?

  • true
  • false
  • 1
  • Error

88. What is the result of the expression '5' '!=' 5 in JavaScript?

  • true
  • false
  • Error
  • Undefined

89. Which function is used to convert a number to a string in JavaScript?

  • toString()
  • toNumber()
  • parseNumber()
  • str()

90. What is the result of the expression 5 > 2 && 3 < 1 in JavaScript?

  • true
  • false
  • Error
  • Undefined

91. What is the JavaScript operator for the bitwise NOT operation?

  • '!'
  • '&&'
  • '||'
  • '~'

92. What is the result of the expression 5 < 2 '||' 3 < 1 in JavaScript?

  • true
  • false
  • Error
  • Undefined

93. What is the purpose of the Math.min() function in JavaScript?

  • To perform mathematical operations
  • To calculate the square root of a number
  • To return the minimum of two or more numbers
  • To round a number to the nearest integer

94. What is the result of the expression 5 >= 5 in JavaScript?

  • true
  • false
  • Error
  • Undefined

95. What is the JavaScript operator for the bitwise shift to the right (with sign) operation?

  • >>
  • <<
  • <<<
  • '&'

96. What is the result of the expression '5' >= 5 in JavaScript?

  • true
  • false
  • Error
  • Undefined

97. What is the purpose of the Math.random() function in JavaScript?

  • To generate random numbers
  • To perform mathematical calculations
  • To round numbers to the nearest integer
  • To check if a variable is defined

98. What is the result of the expression '5' <= 5 in JavaScript?

  • true
  • false
  • Error
  • Undefined

99. Which operator is used to check if a value is strictly greater than another value in JavaScript?

  • >
  • <
  • >=
  • <=

100. What is the result of the expression '5' < '10' in JavaScript?

  • true
  • false
  • Error
  • Undefined

Share with : Share on Linkedin Share on Twitter Share on WhatsApp Share on Facebook