Property and Prototype

What is the difference between “property” and “prototype”? I am stuck in this section. Can someone explain to me? Thanks.

Property belongs to objects (built-in Object). For example:
const obj = {a: 1}; // ‘a’ is a property of obj variable

Regarding Prototypes. JavaScript has 2 types of prototype. They are {}.prototype and {}.proto

They’re inherited by instances of constructors. If you type Object or String in DevTools you would see proto as well as prototype in there. It’s a pretty big subject however it pays off to wrap your head around it since technically everything in JS is an object.

There is a good article on medium concerning prototypes - https://medium.freecodecamp.org/prototype-in-js-busted-5547ec68872

2 Likes

Should be {}.__proto__ – markdown mangled it for you. And yes, it’s an utterly confusing mess, but unless you’re doing something weird like making your own OO system extensions, you shouldn’t have any reason to mess with __proto__ (or even .prototype for that matter unless declaring subclasses by hand). All the more reason to prefer composition over inheritance, I’d say …

2 Likes

Thank you for noticing it, was replying via a mobile device.