Introduction To Javascript Questions
Introduction To Javascript Questions
Please answer these as best as you can. Do not look back to your reviewers or research. After answering all
the questions, self-check by looking at the correct answers. Good luck!
A. To create a constant
B. To declare a variable
C. To define a function
D. To create a block-scoped variable
A. function myFunction() {}
B. function = myFunction() {}
C. def myFunction() {}
D. function: myFunction() {}
A. forEach()
B. loop()
C. repeat()
D. iterate()
A. "null"
B. "object"
C. "undefined"
D. "array"
12. Which method would you use to convert a string to an integer in JavaScript?
A. parseInt()
B. toInteger()
C. convertToInt()
D. stringToInt()
A. ==
B. ===
C. =
D. !=
16. What is a closure in JavaScript?
A. catch block
B. try...catch statement
C. error() function
D. handleError() function
20. Which of the following methods is used to remove the last element of an array in
JavaScript?
A. pop()
B. shift()
C. unshift()
D. splice()
A. setTimeout()
B. setInterval()
C. async/await
D. all()
24. Which event is used to trigger an action when an element is clicked in JavaScript?
A. onmouseover
B. onkeydown
C. onclick
D. onload
A. "number"
B. "NaN"
C. "undefined"
D. "object"
A. form.preventDefault();
B. event.preventDefault();
C. form.stopSubmit();
D. event.stopSubmit();
A. +
B. &
C. concat()
D. +=
29. Which method can be used to check if an object contains a specific property in
JavaScript?
A. object.contains(key)
B. object.hasOwnProperty(key)
C. object.include(key)
D. object.getProperty(key)
A. true
B. false
C. undefined
D. null
31. What does the splice() method do in JavaScript?
A. true
B. false
C. undefined
D. NaN
33. Which of the following is used to add an event listener to an element in JavaScript?
A. element.addEventListener()
B. element.onEvent()
C. element.bindEvent()
D. element.listenEvent()
A. array.copy()
B. array.clone()
C. array.slice()
D. array.duplicate()
35. Which of the following is the correct way to declare a class in JavaScript?
A. class MyClass {}
B. new class MyClass {}
C. class = MyClass {}
D. class MyClass[] {}
A. 11
B. 2
C. 1
D. NaN
A. string.toLowerCase()
B. string.lowerCase()
C. string.makeLower()
D. string.toLower()
A. true
B. false
C. undefined
D. null
A. clearInterval()
B. stopInterval()
C. cancelInterval()
D. endInterval()
A. 10
B. 5
C. 15
D. NaN
45. How can you declare a JavaScript variable that is globally scoped inside a function?
46. Which method is used to search for a substring within a string in JavaScript?
A. indexOf()
B. substring()
C. search()
D. includes()
47. What does the delete operator do in JavaScript?
A. Deletes a variable
B. Deletes a property from an object
C. Deletes an element from an array
D. Deletes a function
48. What is the default value of a JavaScript variable that is declared but not assigned a
value?
A. 0
B. null
C. undefined
D. NaN
A. "hello"
B. 1
C. true
D. "" (empty string)
50. Which of the following methods is used to parse a query string into an object in
JavaScript?
A. URLSearchParams
B. queryParser()
C. parseQueryString()
D. getQueryParams()
GOOD LUCK! AIM HIGH! BE BRAVE!