1

I understand the following is frowned-upon based on its difficulty to optimize (please correct me if I am wrong).

How does this defeat optimization in JavaScript compilers? Is it related to the internal object "classes" present inside V8?

function Parent() {}
function Child() {}

Child.prototype = (function () { 
  var o = {}; 
  o.__proto__ = Parent.prototype; 
  return o; 
}());

Or is it just that __proto__ is a de facto standard that is historically browser-peculiar that makes this approach poor?

Note: I am aware of the correct methods for configuring prototype-chains; this is an academic question.

Ben Aston
  • 53,718
  • 65
  • 205
  • 331

0 Answers0