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 the purpose of JavaScript prototypes?

View

How do you add a method to an existing object's prototype?

View

What is the result of the following code?

View

How do you create an object that inherits from another object?

View

What does Object.create() do in JavaScript?

View

Which of the following methods can be used to copy an object in JavaScript?

View

What is the result of the following code?

View

Which method returns the prototype of an object?

View

Which of the following statements is true about prototypes?

View

How do you check if an object has a specific property and not from its prototype chain?

View

What is the purpose of JavaScript prototypes?

To clone objects
To enable inheritance in JavaScript
To encapsulate properties in an object
To prevent properties from being modified

How do you add a method to an existing object's prototype?

object.prototype.methodName = function() {}
Object.addMethod(object, methodName)
object.prototype = methodName()
object.addPrototype(methodName)

What is the result of the following code?

function Person(name) { this.name = name; } Person.prototype.greet = function() { return "Hello, " + this.name; }; var person = new Person("John"); console.log(person.greet());

Hello, John
undefined
Hello, undefined
Error

How do you create an object that inherits from another object?

Object.create()
Object.assign()
Object.inherit()
Object.prototype()

What does Object.create() do in JavaScript?

Creates a new object with the specified prototype object
Modifies an existing object
Prevents an object from being modified.
Copies all properties from one object to another

Which of the following methods can be used to copy an object in JavaScript?

Object.assign()
Object.create()
Object.prototype()
Object.getPrototypeOf()

What is the result of the following code?

var obj1 = { a: 1 }; var obj2 = Object.create(obj1); console.log(obj2.a);

undefined
1
null
Error

Which method returns the prototype of an object?

Object.getPrototypeOf()
Object.assign()
Object.prototypeOf()
Object.create()

Which of the following statements is true about prototypes?

Every JavaScript object has a prototype.
Prototypes are only used for functions.
Prototypes are used only in ES6 and beyond.
JavaScript does not support prototypes.

How do you check if an object has a specific property and not from its prototype chain?

obj.hasOwnProperty()
"property" in obj
obj.getOwnProperty()
obj.prototype.hasProperty()