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 happens if a property is found on an object but is overwritten on the prototype chain?

View

What is the output of the following code?

View

How can you create an object that inherits from another object in JavaScript?

View

What happens when a method is added to the prototype after an object instance is created?

View

In the following code, what is the purpose of the Object.prototype?

View

How can you prevent an object from being modified, including its prototype?

View

What is the default prototype of an object created from a constructor function?

View

What will the following code output?

View

How can you check if an object directly contains a property (and not its prototype)?

View

What is the prototype chain of an array in JavaScript?

View

What happens if a property is found on an object but is overwritten on the prototype chain?

JavaScript throws an error
The property on the object is used, and the prototype property is ignored
Both the object property and prototype property are used
The prototype property is always preferred

What is the output of the following code?

<p>function Person(name) {<br>&nbsp; this.name = name;<br>}<br>Person.prototype.greet = function() {<br>&nbsp; return "Hello, " + this.name;<br>};<br><br>let john = new Person("John");<br>console.log(john.greet());<br><br></p>

"Hello, John"
undefined
"Hello, undefined"
Error

How can you create an object that inherits from another object in JavaScript?

Object.create()
Object.assign()
Object.copy()
Object.defineProperties()

What happens when a method is added to the prototype after an object instance is created?

The instance cannot access the new method
The new method becomes available to all existing instances
Only future instances can access the new method
JavaScript throws an error

In the following code, what is the purpose of the Object.prototype?

<p>let arr = [];<br>console.log(arr.hasOwnProperty("length"));<br><br></p>

It defines the method used to access object properties
It provides prototype properties to all objects, including arrays
It provides prototype properties to all objects, including arrays
It is specific to function prototypes only

How can you prevent an object from being modified, including its prototype?

Object.freeze()
Object.preventExtensions()
Object.seal()
Object.lock()

What is the default prototype of an object created from a constructor function?

The constructor function itself
Object.prototype
The global object
The instance’s own properties

What will the following code output?

<p>function Animal() {}<br>Animal.prototype.sound = "roar";<br><br>let cat = new Animal();<br>Animal.prototype.sound = "meow";<br><br>console.log(cat.sound);<br><br></p>

"roar"
"meow"
undefined
Error

How can you check if an object directly contains a property (and not its prototype)?

in operator
hasOwnProperty() method
Object.getOwnPropertyNames()
Object.keys()

What is the prototype chain of an array in JavaScript?

Array -> Object -> null
Array -> Object -> Function -> null
Array -> Function -> Object -> null
Array -> Object -> Prototype -> null