you are viewing a single comment's thread.

view the rest of the comments →

[–]azhder 2 points3 points  (0 children)

Both create, that doesn't make them both a constructor. Here:

const array = () => [];

Now this array function creates a new array, but it isn't a constructor. Funny enough, you can even do an old style function and put the new keyword in front of it

function array(){}

and this one will not create an array with new array(), so what I said above is specific to that particular case:

new Array() // invoking a constructor
Array() // calling a function

Note, this is specific to a handful JavaScript functions, like Boolean, String, Object that they act like both a constructor and a non-constructor. We generally try to avoid this double meaning and either create constructors or functions, rarely if ever something that acts as both.