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?

View

What keyword is used to create an object from a function constructor?

View

Which of the following is the correct syntax for a function constructor?

View

What will the following code output? function Person(name) { this.name = name; } const person1 = new Person("Alice"); console.log(person1.name);

View

What is a prototype in JavaScript?

View

What will this code log? function Car() {} Car.prototype.model = "Tesla"; const car1 = new Car(); console.log(car1.model);

View

Can you modify the prototype of a constructor function after objects have been created?

View

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());

View

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);

View

Which of the following is true about function constructors and prototypes?

View

What is a function constructor in JavaScript?

A function that is immediately invoked
A function used to create objects
A function that returns another function
A function that binds this to the global scope

What keyword is used to create an object from a function constructor?

create
new
construct
objectify

Which of the following is the correct syntax for a function constructor?

function Car(model) { this.model = model; }
let Car = (model) => { this.model = model; };
const Car = function(model) { this.model = model; };
function Car(model) { return this.model = model; };

What will the following code output? function Person(name) { this.name = name; } const person1 = new Person("Alice"); console.log(person1.name);

Alice
Undefined
Error
null

What is a prototype in JavaScript?

A blueprint for creating new objects
A function that returns a new object
An internal property of functions that allows inheritance
A method used to initialize objects

What will this code log? function Car() {} Car.prototype.model = "Tesla"; const car1 = new Car(); console.log(car1.model);

Tesla
Undefined
Error
null

Can you modify the prototype of a constructor function after objects have been created?

Yes
No
Only in strict mode
Only before calling new

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());

Hello Bob
Hello undefined
Error
Hello null

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);

Electric
Undefined
Error
null

Which of the following is true about function constructors and prototypes?

Every function has a prototype by default
Function constructors cannot have prototypes
Prototypes can only be modified before object creation
The prototype is only accessible within the function