[Go to site: main page, start]

0% found this document useful (0 votes)
18 views3 pages

JavaScript Quiz: 60 Objective Questions

The document contains a set of 60 objective questions related to JavaScript, covering topics such as variable declaration, data types, functions, control statements, and array methods. Each question provides multiple-choice answers to test knowledge on JavaScript concepts. This resource is useful for individuals preparing for JavaScript assessments or enhancing their programming skills.

Uploaded by

asuzuchidera1234
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views3 pages

JavaScript Quiz: 60 Objective Questions

The document contains a set of 60 objective questions related to JavaScript, covering topics such as variable declaration, data types, functions, control statements, and array methods. Each question provides multiple-choice answers to test knowledge on JavaScript concepts. This resource is useful for individuals preparing for JavaScript assessments or enhancing their programming skills.

Uploaded by

asuzuchidera1234
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

JavaScript Objective Questions (60)

1. Which keyword is used to declare a block-scoped variable in JavaScript? A. var B. let C. const D.
define

2. Which keyword is used to declare a constant variable in JavaScript? A. let B. const C. var D. final

3. What happens if you reassign a value to a const variable? A. It updates the value B. It throws an
error C. It ignores the change D. It converts to var

4. What is the scope of a variable declared with let? A. Global B. Function C. Block D. Module

5. Which keyword allows redeclaration of a variable in the same scope? A. var B. let C. const D.
static

6. Which of the following is a valid variable name? A. 2value B. first_name C. let D. my-value

7. Variable names in JavaScript are case-sensitive. Which two variables are different? A. name and
NAME B. name and Name C. both A and B D. None

8. Which character is NOT allowed in variable names? A. $ B. _ C. - D. letters

9. Which of these is NOT a reserved keyword in JavaScript? A. function B. class C. number D. let

10. What is the default value of an uninitialized variable? A. null B. 0 C. undefined D. false

11. Which of the following is a primitive data type? A. Object B. Array C. Number D. Function

12. Strings in JavaScript are enclosed in? A. Single or double quotes B. Backticks only C. Curly
braces D. Angle brackets

13. Which of these is a non-primitive data type? A. Boolean B. Number C. Object D. String

14. What is the output of typeof undefined? A. null B. object C. undefined D. string

15. What is the output of typeof null? A. null B. object C. undefined D. boolean

16. Which symbol is used to define an array? A. {} B. () C. [] D. <>

17. What is the index of the first element in an array? A. 1 B. 0 C. -1 D. None

18. Which method adds an element at the end of an array? A. shift() B. push() C. pop() D. unshift()

19. Which method removes the last element from an array? A. pop() B. push() C. shift() D. splice()

20. Which method is used to join array elements into a string? A. concat() B. join() C. toString() D.
merge()

21. Which operator is used for strict equality? A. == B. === C. != D. =

22. What is the result of 5 + '5'? A. 55 B. 10 C. NaN D. Error

23. Which operator is used to find remainder? A. % B. / C. * D. //

24. Which operator increments a number by 1? A. -- B. ** C. ++ D. +=

25. Which operator is used for logical AND? A. || B. && C. ! D. ==

26. How do you define a function in JavaScript? A. func myFunction(){} B. function myFunction(){}
C. define myFunction(){} D. fn myFunction(){}

27. What does return do in a function? A. Stops the function and outputs a value B. Pauses the
function C. Prints the value D. None
28. Which keyword is used to define a function? A. func B. function C. fn D. def

29. A function without a return statement returns? A. null B. undefined C. 0 D. false

30. What is a function parameter? A. A value passed into a function B. The result of a function C. A
variable outside the function D. None

31. Which statement executes code if a condition is true? A. else B. if C. switch D. break

32. Which statement provides an alternative when the if condition is false? A. else B. else if C.
switch D. default

33. Which statement allows multiple conditions to be checked in sequence? A. else B. else if C.
switch D. case

34. Which statement is used to evaluate multiple options? A. if B. else C. switch D. while

35. In a switch statement, which keyword is used to end a case? A. break B. stop C. return D. end

36. Which property returns the length of a string? A. count B. size C. length D. index

37. Which method converts a string to uppercase? A. toUpperCase() B. upper() C. convertUpper()


D. capitalize()

38. Which method returns part of a string? A. slice() B. split() C. join() D. indexOf()

39. Which method searches for a string within another string? A. search() B. find() C. includes() D.
match()

40. Which method replaces part of a string? A. replace() B. swap() C. change() D. switch()

41. Which property gives the number of elements in an array? A. size B. count C. length D. index

42. Which method adds elements at the beginning of an array? A. push() B. unshift() C. pop() D.
shift()

43. Which method removes the first element of an array? A. unshift() B. shift() C. slice() D. pop()

44. Which method merges two or more arrays? A. merge() B. concat() C. join() D. push()

45. Which method checks if an array includes a certain value? A. find() B. search() C. includes() D.
contains()

46. Which array method executes a function once for each element? A. forEach() B. map() C. filter()
D. reduce()

47. Which method creates a new array with elements that pass a condition? A. map() B. filter() C.
forEach() D. reduce()

48. Which method creates a new array by applying a function to each element? A. map() B. filter()
C. forEach() D. reduce()

49. Which method reduces an array to a single value? A. forEach() B. reduce() C. map() D. filter()

50. Which loop is commonly used to iterate over arrays? A. for B. while C. do...while D. switch

51. Which object is used to work with dates in JavaScript? A. Date B. Time C. Calendar D. Clock

52. Which method gets the current date and time? A. [Link]() B. new Date() C. [Link]() D.
getDate()

53. Which method returns the day of the week from a Date object? A. getDay() B. getDate() C.
getMonth() D. getYear()
54. Which Math method returns the largest integer less than or equal to a number? A. [Link]()
B. [Link]() C. [Link]() D. [Link]()

55. Which Math method returns a random number between 0 and 1? A. [Link]() B.
[Link]() C. [Link]() D. [Link]()

56. Which object represents the browser window? A. screen B. document C. window D. console

57. Which method displays an alert box with a message? A. [Link]() B. [Link]() C.
[Link]() D. [Link]()

58. Which method writes content into the HTML document? A. [Link]() B. [Link]()
C. [Link]() D. [Link]()

59. Which method is used to ask the user for input in a dialog box? A. alert() B. confirm() C.
prompt() D. input()

60. Which method is used to open a new browser window? A. [Link]() B. [Link]() C.
[Link]() D. [Link]()

You might also like