MDN says that every JavaScript object has a prototype property that is not actually called prototype
:
Every object in JavaScript has a built-in property, which is called
its prototype. … The property of an object that points to its
prototype is not calledprototype
. Its name is not standard, but in
practice all browsers use__proto__
. The standard way to access an
object’s prototype is theObject.getPrototypeOf()
method.
Why then do React components have a property called exactly prototype
?
I can see this property from the Javascript console when creating a React app with create-react-app
and logging App.prototype
to the console:
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
<React.StrictMode>
<App />
</React.StrictMode>
);
console.log(App.prototype);
The log returns an object.