javascript - Difference between function and constructor function -


I want to know the difference between the function and the constructor function.

General function

function = dosomething () {// do something};

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

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -