












































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Focused on dynamic web development, this exam assesses knowledge of DHTML (Dynamic HTML) and JavaScript. Topics include DOM manipulation, event handling, form validation, and creating interactive web pages.
Typology: Exams
1 / 84
This page cannot be seen from the preview
Don't miss anything!













































































Question 1. Which of the following keywords in JavaScript does NOT support block-level scoping? A) let B) const C) var D) None of the above Answer: C Explanation: The var keyword is function-scoped, not block-scoped, whereas let and const are block- scoped. Question 2. What is the result of the following expression: typeof null? A) "null" B) "object" C) "undefined" D) "boolean" Answer: B Explanation: In JavaScript, typeof null returns "object" due to a legacy bug. Question 3. Which operator checks both value and type for equality? A) == B) != C) === D) = Answer: C Explanation: The strict equality operator (===) compares both value and type.
Question 4. What will be the result of 5 + "5" in JavaScript? A) 10 B) "55" C) NaN D) Error Answer: B Explanation: The number is coerced to a string, resulting in string concatenation. Question 5. Which logical operator returns true only if both operands are true? A) || B) && C)! D) ?? Answer: B Explanation: The AND operator (&&) returns true only when both operands are true. Question 6. What is the default value of an uninitialized variable declared using var? A) null B) undefined C) 0 D) "" Answer: B Explanation: Uninitialized variables have the value undefined by default.
Question 10. Which of the following is a falsy value in JavaScript? A) "false" B) 1 C) 0 D) "0" Answer: C Explanation: 0 is a falsy value; "false" and "0" are truthy strings. Question 11. What does the following statement return: Boolean("") A) true B) false C) undefined D) null Answer: B Explanation: An empty string is falsy, so Boolean("") returns false. Question 12. What is the output of typeof Symbol('id')? A) "object" B) "symbol" C) "string" D) "function" Answer: B Explanation: typeof Symbol('id') returns "symbol".
Question 13. Which of the following is NOT a primitive type in JavaScript? A) Object B) Number C) String D) Boolean Answer: A Explanation: Object is not a primitive type. Question 14. Which operator can be used to combine two or more strings? A) + B) * C) & D) | Answer: A Explanation: The + operator concatenates strings. Question 15. What is the result of '10' == 10? A) true B) false C) undefined D) Error Answer: A Explanation: == performs type coercion, so '10' == 10 is true.
Question 19. What does the following code return: typeof undefined? A) "null" B) "undefined" C) "object" D) "boolean" Answer: B Explanation: typeof undefined is "undefined". Question 20. What is the result of Boolean(NaN)? A) true B) false C) undefined D) NaN Answer: B Explanation: NaN is a falsy value. Question 21. Which statement will correctly check if a variable is NOT undefined? A) variable !== undefined B) variable = undefined C) variable == null D) variable === null Answer: A Explanation: !== checks both value and type.
Question 22. What does the following code output: console.log(2 ** 3)? A) 6 B) 8 C) 9 D) 23 Answer: B Explanation: ** is the exponentiation operator; 2 ** 3 = 8. Question 23. Which of the following is a valid way to declare a variable? A) variable name B) let name C) declare name D) define name Answer: B Explanation: let is used to declare variables. Question 24. Which operator is used for strict inequality? A) != B) !== C) = D) == Answer: B Explanation: !== checks both value and type for inequality.
Question 28. Which statement creates a constant whose value cannot be changed? A) var PI = 3.14; B) const PI = 3.14; C) let PI = 3.14; D) PI = 3.14; Answer: B Explanation: const declares a constant. Question 29. Which of the following is NOT a valid JavaScript variable name? A) $value B) _value C) value D) 1value Answer: D Explanation: Variable names cannot begin with a digit. Question 30. Which statement is true about type coercion in JavaScript? A) It happens only with strict equality. B) It converts values to a common type when using ==. C) It prevents comparison of different types. D) It throws errors for mismatched types. Answer: B Explanation: == triggers type coercion.
Question 31. Which of these will result in NaN? A) "5" + 5 B) "five" - 2 C) 5 * "5" D) "10" / 2 Answer: B Explanation: "five" cannot be converted to a number. Question 32. What is the output of typeof function() {}? A) "object" B) "function" C) "undefined" D) "null" Answer: B Explanation: typeof for functions returns "function". Question 33. Which keyword allows variable declaration with block scope? A) var B) let C) function D) static Answer: B Explanation: let creates block-scoped variables.
Question 37. Which operator can be used for logical OR? A) && B) || C) ?? D)! Answer: B Explanation: || is the logical OR operator. Question 38. Which keyword is used for declaring variables with function scope? A) const B) let C) var D) static Answer: C Explanation: var is function-scoped. Question 39. Which of the following is NOT a comparison operator? A) == B) === C) <= D) ++ Answer: D Explanation: ++ is an increment operator.
Question 40. What will the following output: typeof NaN? A) "undefined" B) "object" C) "number" D) "NaN" Answer: C Explanation: typeof NaN is "number". Question 41. Which statement is true about variables declared using const? A) Their value can be changed. B) Their reference cannot be changed. C) They are always global. D) They are block-scoped. Answer: D Explanation: const is block-scoped. Question 42. What does the following code output: console.log(!true)? A) true B) false C) undefined D) null Answer: B Explanation: !true is false.
Question 46. Which primitive type represents unique, immutable values? A) Symbol B) Number C) String D) Object Answer: A Explanation: Symbol represents unique values. Question 47. What is the output of Boolean("false")? A) true B) false C) undefined D) null Answer: A Explanation: Non-empty strings are truthy. Question 48. Which operator is used to access object properties? A). B) [] C) () D) {} Answer: A Explanation:. is used to access object properties.
Question 49. Which of the following is NOT a primitive type? A) Boolean B) Object C) String D) Undefined Answer: B Explanation: Object is not a primitive type. Question 50. What does the following code output: typeof 123n? A) "number" B) "bigint" C) "undefined" D) "object" Answer: B Explanation: typeof 123n returns "bigint". Question 51. Which statement is used for conditional branching? A) if B) for C) switch D) while Answer: A Explanation: if is used for conditional branching.
Question 55. Which keyword skips the current loop iteration? A) break B) continue C) return D) exit Answer: B Explanation: continue skips to the next iteration. Question 56. Which loop iterates over the values of an array? A) for...in B) for...of C) while D) switch Answer: B Explanation: for...of iterates over values. Question 57. Which loop iterates over the keys of an object? A) for...in B) for...of C) while D) if Answer: A Explanation: for...in iterates over object keys.
Question 58. What does the following code output: for (let i = 0; i < 3; i++) { console.log(i); } A) 0 1 2 B) 1 2 3 C) 0 1 2 3 D) 1 2 Answer: A Explanation: Loop runs for i = 0, 1, 2. Question 59. Which statement is used to declare a function? A) function name() {} B) let name = function() {} C) const name = () => {} D) All of the above Answer: D Explanation: All three declare functions in different ways. Question 60. What is the scope of a function declared within another function? A) Global B) Block C) Local to the outer function D) Object Answer: C Explanation: Inner functions are scoped locally.