javascript - Difference between function and constructor function -
I want to know the difference between the function and the constructor function.
General function
Constructor function
function = Dosomething () {// do something};
Why do we have the capital of the first letter in the constructor function? There is no specific reason behind it
there is no difference - using a capital letter for a function is a function During the making, there is a best practice which will act as a producer.
The reason this is how you behave in a way that behaves them differently is because the function is the first class in Javascript.
For example:
function myRegularFunction () {console.log ("regular"); } MyRegularFunction (); My Function: MyObject Function () {console.log ("object" MyInstance.myMethod ();
Hope that helps.
Comments
Post a Comment