tell me when js function will be called as constructor function ?
if we write a simple js function then it will be called as constructor function ?
- function myFunction(a, b) {
- return a * b;
- }
-
- var x = myFunction(4, 3);
so tell me
myFunction() will be consider as constructor function ? if no then describe the reason.
tell me why below js function is consider as constructor function ?
- function person(first, last, age, eye) {
- this.firstName = first;
- this.lastName = last;
- this.age = age;
- this.eyeColor = eye;
- }
- var myFather = new person("John", "Doe", 50, "blue");
- var myMother = new person("Sally", "Rally", 48, "green");
when new keyword will be used to call js function then it will be consider as constructor function ?
please guide me. thanks