




























































































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
Advanced JavaScript programming exam. Topics include DOM manipulation, AJAX, JSON, client-side validation, and modern frameworks.
Typology: Exams
1 / 177
This page cannot be seen from the preview
Don't miss anything!





























































































Question 1. Which of the following best describes JavaScript as a language? A) Compiled, object-oriented B) Interpreted, object-based C) Compiled, procedural D) Interpreted, functional Answer: B Explanation: JavaScript is an interpreted, object-based scripting language, commonly used for client-side web development. Question 2. Which statement correctly declares a variable in JavaScript? A) var myVar; B) int myVar;
C) let: myVar; D) variable myVar; Answer: A Explanation: JavaScript variables are declared using 'var', 'let', or 'const', but not with 'int' or 'variable'. Question 3. What is the output of: console.log(typeof true);? A) boolean B) string C) number D) object Answer: A
D) Error Answer: B Explanation: The number 2 is coerced to a string and concatenated, resulting in "22". Question 6. Which of the following is NOT a primitive data type in JavaScript? A) String B) Number C) Object D) Boolean
Answer: C Explanation: Objects are not primitive; they are reference types. Question 7. Which symbol is used for strict equality comparison in JavaScript? A) == B) = C) === D) !== Answer: C Explanation: '===' checks for both value and type equality (strict equality).
Answer: B Explanation: '=' is the assignment operator. Question 10. What is the default value of an uninitialized variable in JavaScript? A) null B) 0 C) undefined D) "" Answer: C
Explanation: Uninitialized variables are assigned 'undefined' by default. Question 11. What is the scope of a variable declared with 'var' inside a function? A) Global B) Block-level C) Function-level D) Local to block Answer: C Explanation: Variables declared with 'var' inside a function have function-level scope.
C) instanceof D) istype Answer: A Explanation: The 'typeof' operator returns the data type of its operand. Question 14. What will the following code output? console.log([] == false); A) true B) false C) Error D) undefined Answer: A
Explanation: [] is coerced to '' (empty string), which is falsy, so [] == false is true. Question 15. Which statement is used to create a new function in JavaScript? A) function myFunction() {} B) func myFunction() {} C) define myFunction() {} D) def myFunction() {} Answer: A Explanation: Functions are declared with the 'function' keyword. Question 16. How do you write a single-line comment in JavaScript?
D) All of the above Answer: D Explanation: All listed options are valid ways to define an anonymous function. Question 18. What is a closure in JavaScript? A) A function having access to parent scope B) A method attached to an object C) A variable outside any function D) An object with private properties Answer: A Explanation: Closure is when a function retains access to its outer scope variables.
Question 19. What does the 'onclick' event handler respond to? A) Keyboard input B) Mouse click C) Form submission D) Mouse hover Answer: B Explanation: 'onclick' responds to mouse click events. Question 20. Which of the following statements creates an array? A) var arr = (1,2,3); B) var arr = [1,2,3];
Question 22. Identify the correct syntax for an 'if' statement. A) if x > 5 then { ... } B) if (x > 5) { ... } C) if x > 5: { ... } D) if (x > 5): { ... } Answer: B Explanation: The condition must be in parentheses. Question 23. What is the output of the following code? for (var i = 0; i < 3; i++) { console.log(i); } A) 0 1 2 3
Answer: B Explanation: The loop runs for i = 0, 1, 2. Question 24. How do you check if a variable 'x' is not equal to 10? A) x != 10 B) x !== 10 C) Both A and B D) x =/ 10 Answer: C
A) for B) do...while C) foreach D) while Answer: C Explanation: 'foreach' is not a loop statement in standard JavaScript (it's an Array method). Question 27. What does the 'continue' statement do in a loop? A) Terminates the loop B) Skips the current iteration C) Returns a value
D) Exits the function Answer: B Explanation: 'continue' skips current iteration and continues with the next. Question 28. Which built-in object allows working with dates and times? A) Timer B) Date C) Calendar D) Time Answer: B Explanation: The Date object is used for dates and times.