I am currently learning JavaScript through my institution and I am reading about how in JavaScript, functions are objects and how it has a prototype (don't know what that is since the lesson never explained what prototype is). Coming from a background in Java, you might understand how confusing this is to me. I decided to search Google for any references on how functions are objects and keep seeing that you can write a constructor like this:
function Person(first, last, age, eyecolor) {
this.firstName = first;
this.lastName = last;
this.age = age;
this.eyeColor = eyecolor;
}
But I know that a regular function is written as such:
function multiplyNumbers(a, b) {
return a * b;
}
So how does JavaScript know when I am making a regular function and when I am making a constructor if they are written pretty much the same way?