Instructions
- 1. Your final score will reflect your grasp of the concepts—approach each question with precision.
- 2. Thoroughly review each solution before proceeding to ensure full understanding.
- 3. Final results will be available after submission to provide insights into areas for further improvement.
- 4. Maintain academic integrity—plagiarism undermines learning and professional growth.
- 5. Once submitted, responses are final, so ensure you’re confident in your answers.
- 6. These challenges are designed to test practical knowledge; apply your skills as you would in real-world scenarios.
All Problems
Question
Action
What is a function constructor in JavaScript?
What keyword is used to create an object from a function constructor?
Which of the following is the correct syntax for a function constructor?
What will the following code output? function Person(name) { this.name = name; } const person1 = new Person("Alice"); console.log(person1.name);
What is a prototype in JavaScript?
What will this code log? function Car() {} Car.prototype.model = "Tesla"; const car1 = new Car(); console.log(car1.model);
Can you modify the prototype of a constructor function after objects have been created?
What is the output of this code? function Person(name) { this.name = name; } Person.prototype.greet = function() { return "Hello " + this.name; }; const person1 = new Person("Bob"); console.log(person1.greet());
What will the following code print? function Car(model) { this.model = model; } Car.prototype = { type: "Electric" }; const car1 = new Car("Tesla"); console.log(car1.type);
Which of the following is true about function constructors and prototypes?