Why JavaScript Classes Are Actually Functions | Prototypal Inheritance Explained

preview_player
Показать описание
While JavaScript fully supports object oriented programming, it doesn't work how you might be used to. Classes are simply syntactic sugar around the prototypical inheritance system based on function constructors. Here's a quick breakdown on how it all works.

Prepping for your frontend interviews? Use code "conner" for a discount on my course FrontendExpert:

Socials:
Рекомендации по теме
Комментарии
Автор

As a Java developer it very useful to me that having a Class in JavaScript so I can do OOP like inheritance with the use of extends, abstraction using implements.

yerenzter
Автор

I wanna learn javascript and this is a pretty neat way to show what all things you can do so easily in it, also gives me more motivation for it

Cluttergg
Автор

If you're confused about this concept, I recommend you learn about the "proto chain"

bubble
Автор

I wrote my own programming language on top of JS and when I had to implement a class system, I realized that if you don’t do this then you end up with a language that is insanely slow as it’s copying unnecessary code over and over of course… and I didn’t know about this yet but it was intuitive I think I thought .bind for like one second and then was like shit… this had to be one of it not my favorite realizations about programming languages ever ….

Iriscgldom
Автор

The syntactic sugar in this case makes it look cleaner in this case

astrahcat
Автор

Is the 'prototype' an actual prototype for the constructor function ?
If not, then what is the prototype for the constructor function since it also an object

davesharma
Автор

hi conner, I'm from India can u make a JS full course

dheerajsan
Автор

I found a much better and in depth explanation for this in an article on medium: Prototypal Object-Oriented Programming in Javascript by Prateek

prateek
Автор

JavaScript, a programming language hastily written in a week, is packed with syntactic sugar that aims to simplify tasks already elegantly handled by other languages. It’s riddled with quirky decisions that baffle developers. TypeScript tried to patch these flaws, making some improvements, but it still falls short of what we truly need for a modern web ecosystem. The future? We need a new language for the web. WebAssembly shows promise, but it's too early to bet on it.

f.hasni-tv
Автор

I think something telling me it should be an object.
but I once see typescript making it a function. hmm

asagiai