Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Javascript, can every function be considered a constructor of a class? [duplicate]

I don't see any syntactic difference between an ordinary function, and one which behaves like a constructor for a class. So are they the same?

Does this mean that every single function we define has a property named 'prototype' by default?

like image 915
Shailesh Tainwala Avatar asked May 22 '26 12:05

Shailesh Tainwala


1 Answers

Yes, every function has a property named prototype by default. The "construction" functionality is provided by the [[Construct]] internal property(invoked by new F()), which is set for every created function(see http://es5.github.io/#x13.2 - creating function objects, p18)

like image 136
Sacho Avatar answered May 24 '26 01:05

Sacho



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!