proto VS prototype in JavaScript

0 votes

The figure in the image below once again shows me that every object has a prototype. Constructor function Foo also has its own __proto__ which is Function.prototype, and which in turn also references via its __proto__ property again to the Object.prototype. Thus, repeat, Foo.prototype is just an external property of Foo which refers to the prototype of b and c objects.

var b = new Foo(20); var c = new Foo(30);


What are the differences between __proto__ and prototype?

enter image description here

Feb 22, 2022 in Java by Rahul
• 9,670 points
1,385 views

1 answer to this question.

0 votes

To answer your query, the __proto__ is the actual object that is used in the lookup chain to resolve methods whereas, the prototype is the object that is used to build __proto__ when you create an object with new:

( new Foo ).__proto__ === Foo.prototype; 
( new Foo ).prototype === undefined;

answered Feb 22, 2022 by Aditya
• 7,680 points

Related Questions In Java

0 votes
1 answer

Which equals operator (== vs ===) should be used in JavaScript comparisons?

I hope this is what you're looking for: const today = new Date(); const yyyy = ...READ MORE

answered Nov 4, 2022 in Java by Damonlang
• 700 points
282 views
+1 vote
1 answer

concat() vs “+” operator : In Java for String concatenation

Basically, there are two important differences between ...READ MORE

answered Apr 27, 2018 in Java by Rishabh
• 3,620 points
4,470 views
0 votes
1 answer

Comparable vs Comparator in Java

I think you are not alone who is ...READ MORE

answered May 11, 2018 in Java by code.reaper12
• 3,500 points
872 views
0 votes
1 answer

@Component vs @Repository vs @Service in Spring Framework

As you might be knowing, all these ...READ MORE

answered May 29, 2018 in Java by geek.erkami
• 2,680 points
3,340 views
0 votes
0 answers

Length of a JavaScript object

I have a Javascript object and want ...READ MORE

May 23, 2022 in Java-Script by Kichu
• 19,050 points
364 views
0 votes
0 answers

Object.values() in jQuery

The prototypeJS library has a method Object.values() ...READ MORE

Aug 8, 2022 in Web Development by gaurav
• 23,260 points
2,170 views
0 votes
0 answers

How do I check if an array includes a value in JavaScript?

What is the shortest and most efficient ...READ MORE

Sep 28, 2022 in Java by Nicholas
• 7,760 points
441 views
0 votes
0 answers

Check if a value is an object in JavaScript

How do you check if a value ...READ MORE

Dec 7, 2022 in Java by Nicholas
• 7,760 points
223 views
0 votes
1 answer

How do I get the current date in JavaScript?

To ensure that you get the current ...READ MORE

answered Feb 18, 2022 in Java by Aditya
• 7,680 points
397 views
0 votes
1 answer

Parsing a string to a date in JavaScript

The best string format for string parsing ...READ MORE

answered Feb 18, 2022 in Java by Aditya
• 7,680 points
412 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP