TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
tri_inn
NA
1.2k
233.5k
Javascript What is constructor function
Jun 29 2017 9:27 AM
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
Reply
Answers (
2
)
how to stop parent div method calling
Global variable is not updated javascript