




























































































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
A set of questions and answers related to javascript programming, likely intended for exam preparation or self-assessment. It covers fundamental concepts such as object creation, property access, inheritance, string manipulation, and asynchronous programming. Each question is followed by the correct answer and a brief explanation, making it a useful resource for students or professionals looking to test their knowledge of javascript. The questions are designed to assess understanding of core language features and best practices, providing valuable insights into the key areas of javascript development. This resource is ideal for those preparing for a javascript certification exam or seeking to reinforce their understanding of the language.
Typology: Exams
1 / 191
This page cannot be seen from the preview
Don't miss anything!





























































































Question 1. Which method creates a new object with a specified prototype in JavaScript? A) Object.defineProperty() B) Object.create() C) Object.assign() D) Object.freeze() Answer: B Explanation: Object.create() is used to create a new object with the specified prototype object. Question 2. What is the correct syntax to access a property called "name" in an object called user?
A) user(name) B) user->name C) user.name D) user:name Answer: C Explanation: Dot notation (user.name) is the standard way to access a property in JavaScript. Question 3. How can you check if an object has a property as its own property (not inherited)? A) object.in(property) B) property in object
Answer: B Explanation: The delete operator removes a property from an object. Question 5. How do you enumerate all keys (own and inherited) of an object? A) Object.keys(obj) B) Object.values(obj) C) for...in loop D) Object.entries(obj) Answer: C Explanation: The for...in loop iterates over all enumerable properties, including inherited ones.
Question 6. What is the result of comparing two different objects with the same properties using == or ===? A) true B) false C) undefined D) Throws error Answer: B Explanation: Objects are compared by reference, not by value, so different objects are never equal.
A) Refers to parent function B) Refers to the global object always C) Refers to the object the method is called on D) Refers to the class only Answer: C Explanation: "this" within a method refers to the object from which the method is called. Question 9. How do you define a getter for a property "fullName" in an object? A) get fullName() {} B) function get fullName() {}
C) fullName.get = function() {} D) fullName() {} Answer: A Explanation: The proper getter syntax is get fullName() {} inside the object. Question 10. What does Object.freeze(obj) do? A) Prevents adding or removing properties B) Makes object immutable C) Prevents modification of existing properties’ values D) All of the above Answer: D
A) class B extends A B) class B inherits A C) class B : A D) class B - > A Answer: A Explanation: The extends keyword implements inheritance between classes in ES6. Question 13. How can you call a parent class constructor from a subclass in JavaScript? A) super() B) parent()
C) this.super() D) extends() Answer: A Explanation: super() is used inside the subclass constructor to call the parent class constructor. Question 14. Which method defines a static property in a class? A) static myMethod() {} B) static: myMethod() {} C) myMethod static() {} D) myMethod() static {} Answer: A
Question 16. Which method converts a string to uppercase in JavaScript? A) toUpper() B) uppercase() C) toUpperCase() D) makeUpperCase() Answer: C Explanation: toUpperCase() converts all the letters in a string to uppercase. Question 17. What does arr.splice(1,2) do in an array [0,1,2,3,4]? A) Removes 2 elements starting from index 1
B) Adds 2 elements at index 1 C) Returns the first two elements D) Splits the array in half Answer: A Explanation: splice(1,2) removes 2 elements starting from index 1. Question 18. Which method finds the first element matching a condition in an array? A) find() B) filter() C) map() D) sort()
Explanation: Set only allows unique values and automatically removes duplicates. Question 20. Which method adds or updates an entry in a Map object? A) set() B) put() C) add() D) insert() Answer: A Explanation: set() is used to add or update entries in a Map. Question 21. What is the output of JSON.stringify({a:1, b:2})?
A) {a:1,b:2} B) "a:1,b:2" C) '{"a":1,"b":2}' D) undefined Answer: C Explanation: JSON.stringify() converts objects into a JSON string. Question 22. How do you test a string for a regular expression match in JavaScript? A) test() B) exec() C) match()
Explanation: Extending built-in prototypes can cause conflicts and unexpected behavior. Question 24. What is a generator function in JavaScript? A) A function that generates random numbers B) A function that can pause and resume execution C) A function that returns another function D) A function that runs asynchronously Answer: B Explanation: Generator functions can pause execution and resume later, using the yield keyword.
Question 25. What is the syntax to define a generator function? A) function* myGen() {} B) generator myGen() {} C) function myGen() {} D) function myGen() yield {} Answer: A Explanation: The asterisk after function (function) defines a generator function. Question 26. What is the purpose of Promise.all()? A) To resolve the fastest promise B) To wait for all promises to resolve or any to reject