Hi, Iam trying to understand prototype chain if anyone can explain it that would be so helpful.
Thanks
Hey there,
so what specific issue do you have?
What did you try to learn it?
Which tutorial or article did you try to understand?
hi,
Iam trying to understand prototype chain in javascript----------------
All objects in JavaScript (with a few exceptions) have a prototype
. Also, an object’s prototype
itself is an object.
function Bird(name) {
this.name = name;
}
typeof Bird.prototype; // yields 'object'
Because a prototype
is an object, a prototype
can have its own prototype
! In this case, the prototype
of Bird.prototype
is Object.prototype
:
(I dont understand this line----)
Object.prototype.isPrototypeOf(Bird.prototype); // returns true
Hey there,
great work so far!
So I would start to learn more about Object-oriented programming in general, WHY it was created and WHY we use it.
Then I would look into Class-based programming and Prototype-based programming, how they differ and what are the pros and cons of each approach.
I think by doing this a lot of questions get a lot more clearer.
Hi,
Thanks,
I have one more question do we use protype inheritance or class inheritance in industry, and which one is more efficient.
In like 95% of the projects you don’t build new stuff, but add code to existing projects, so you mostly use whatever the existing code uses.
Efficient in relation to what/whom?
If you need better performance, you probably use a different programming language.
Thanks,
being a fresher i was not aware of this that—
“In like 95% of the projects you don’t build new stuff, but add code to existing projects, so you mostly use whatever the existing code uses.”
To me it was making new things every day.
Thanks a lot
As pototypal inheritance is how OO in JS works, if you are using JS you can’t use anything else, so it’s fine. It isn’t used in any other widely used languages, was just a design choice in JS. Also unsure what you mean by “efficient”