JavaScript Prototype Fun

JavaScript Prototype Fun

Kyle Robinson Young

10 лет назад

9,478 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@shikhaverma1337
@shikhaverma1337 - 18.11.2015 04:34

Thanks for creating such an awesome video!!!!!

Ответить
@gxvigo
@gxvigo - 16.01.2016 08:12

Hi Kyle, good stuff, your videos are always a guarantee of learning something effectively.

There are 2 things I still don't understand.
1_ difference between 'new' and 'Object.create()
2_ if I create a function in the constructor I can access that from any instance of the constructor:
function Bear(kind) {
this.kind = kind;
this.growl = function() {
console.log('grrr');
}
}
var polar = new Bear('polar');
polar.growl() // -> 'grrr'

What am I missing?

Cheers, Giovanni

Ответить
@syedfaizan92
@syedfaizan92 - 11.02.2016 20:23

You could also use new Bear() instead of Object.create(Bear.prototype)

Ответить
@FaizanShakeelKhan
@FaizanShakeelKhan - 15.04.2016 23:32

In JavaScript, Its always Prototypal under the hood, because objects share properties through their prototype property.
The way of doing this inheritance showed in this video is not Prototypal, its Classical.

Ответить
@OsnySantosNetto
@OsnySantosNetto - 12.05.2016 00:40

Can you share your gulp/grunt script to live reload?

Ответить
@pvsrinivas100
@pvsrinivas100 - 26.05.2016 05:44

Kyle, thanks for the great tutorial. I have a question, wondering if you can answer...you are doing
Grizzly.prototype = Object.create(Bear.prototype)

1) Can I do this instead? Grizzly.prototype = new Bear(); If so, what are the differences. Thanks

Ответить
@ravuribabu1
@ravuribabu1 - 08.07.2016 12:18

great video

Ответить
@has4tis
@has4tis - 12.07.2016 04:50

Very brief but spot on! Very clearly explained! Great job!

Ответить
@highfivebear
@highfivebear - 26.07.2016 19:27

hello, Kyle! thanks for the video, but I can't get the one difference (sorry, If I repeat the topic, I haven't find the same question): is there any difference between assigning properties/methods via prorotype where all instances will inherit all the properties and just adding that same properties/methods to the 'class' himself where all instances via 'new' will inherit all the properties!
hah, is there?:) thanks!

and probably you cound use Grizzly.prototype = bear to inherit bear object's properities, right?

Ответить
@flamboulder
@flamboulder - 06.08.2016 23:52

This was absolutely fantastic and incredibly concise thank you sir!

Ответить
@KarthikCSSJCE
@KarthikCSSJCE - 08.08.2016 02:34

Awesome explanation! But there's something I don't understand. While inheriting, if we use

Grizzly.prototype = new Bear(); , you do not need the line to call the parent constructor // Bear.call(this); to inherit parent's member funcs and vars.

However u need it when doing Grizzly.prorotype = Object.create(Bear.prototype);
So what is the difference ?


Also when u use the former way to inherit, it truly inherits everything from parent. Everything declared in the constructor too(not just the ones in the parent's prototype). But when you use the latter way without the line (Bear.call(this);) it only inherits the vars in the parent's prototype, not the vars and funcs in the actual Parent constructor. As soon as you include (Bear.call(this)) you have access to everything in the constructor too. What is this behavior. Could you please explain that ?

Ответить
@ThaEzioAuditore
@ThaEzioAuditore - 15.08.2016 11:58

Interesting concept, I wonder why JavaScript is the only language to implement object oriented programming that way ! Also, what would happen if you didn't use object.create and instead passed the bear prototype as the grizzly prototype ? doest that mean that if you change the grizzly prototype its parent prototype will be modified too ? thanks for sharing the knowledge btw 😂😂

Ответить
@violinsheetmusicblog
@violinsheetmusicblog - 19.09.2016 05:34

How do you comment out lines so fast?

Ответить
@nabeelalisajid
@nabeelalisajid - 26.09.2016 16:02

This is basic inheritance not prototypal?

Ответить
@zoecarlibur
@zoecarlibur - 09.11.2016 18:16

awesome tutorial

Ответить
@dwarslopers
@dwarslopers - 20.11.2016 21:07

Hey Kyle, you did a very good video! Many Thanks for sharing it !!!

Ответить
@BigMoneySniper
@BigMoneySniper - 07.12.2016 11:27

Hold on.... I'm a bit confused... I thought with Prototype Inheritance you don't use the new keyward to instanciate an object.... I thought now its Object.create({ property:value}) for inhertiance.... I think this is classical inheritence. so confused.

Ответить
@whiskey4609
@whiskey4609 - 20.12.2016 10:29

do you have to set the constructor of Grizzly again by Grizzly.prototype.constructor = Grizzly.prototype?

Ответить
@manelet
@manelet - 22.02.2017 20:53

insta sub

Ответить
@victorayodele4590
@victorayodele4590 - 12.03.2017 01:11

I had to log in to my google account just to say thank you for this well explained video... Thanks!

Ответить
@JPDevuyst
@JPDevuyst - 04.05.2017 18:53

I've been trying to figure this out for a long time and this is the best explanation I've found! Thank you!

Ответить
@jsnode2075
@jsnode2075 - 26.05.2017 09:29

What is the name of the extension for live reload?

Ответить
@lukegibson2683
@lukegibson2683 - 16.06.2017 13:27

This guy sounds like Seth Rogen - also great video!

Ответить
@mralextacy
@mralextacy - 22.02.2018 01:08

Very good Kyle, thanks

Ответить
@kensleylewis
@kensleylewis - 07.03.2018 07:17

There appears to be a mixture of Inheritance Patterns going on within this single tutorial. As a result, this brings confusion between composition (what the grizzly can do) and inheritance (the grizzly himself). Towards the end, things begin to get a little confusing (you can even hear it in his voice), because there is no clear cut way in organizing it all. Sense Object.create was needed halfway through this tutorial, it would make sense to start and end this tutorial with object delegation and composition, without the need of a constructor function. By going down this road, new JavaScript users will see the different styles to JavaScript programming.

Ответить
@mauriciodarocha
@mauriciodarocha - 13.05.2018 19:36

Great Tutorial! Could you increase the font a little for the next videos? I would appreciate it. ;)

Ответить
@alexvonstuelpnagel8189
@alexvonstuelpnagel8189 - 28.05.2018 20:20

you sound like mordecai from regular show

Ответить
@richangvg
@richangvg - 04.08.2018 03:23

This is amazing!!!!!

Ответить
@anowlonedge1815
@anowlonedge1815 - 21.10.2018 12:44

Simple and to the point. Thanks!

Ответить
@MylesGmail
@MylesGmail - 16.12.2018 22:54

Good video, I'll tweet it. Thx.

Ответить
@floopy312
@floopy312 - 24.03.2019 06:53

Beautiful explanation. Thank you.

Ответить
@PierreSoubourou
@PierreSoubourou - 13.04.2019 08:35

Impossible to read on smartphone

Ответить
@regeleionescu935
@regeleionescu935 - 09.06.2019 22:14

You made me understand class, prototype, instancing in less than 10 minutes, thank you!

Ответить
@Skynet-Online
@Skynet-Online - 22.08.2019 20:21

Great explanation thanks for making this video!

Ответить
@danielm.borges6820
@danielm.borges6820 - 11.04.2020 18:25

Thank you so much, in a few minutos I got how the JavaScript Prototype works.

Ответить
@kennytong1707
@kennytong1707 - 23.05.2020 20:31

Very clear for me as a Javascript newbie!

Ответить
@henriquehefler4159
@henriquehefler4159 - 15.06.2020 21:11

Awesome tutorial, simple but not incomplete.

Ответить
@christianrodier3381
@christianrodier3381 - 17.06.2020 05:50

That was helpful

Ответить
@dominykasraila
@dominykasraila - 17.10.2020 11:18

Thank you for the video. I liked the pace. The code we write for applications with JS at work is very procedural: lots of global scope functions, variables. I am looking for ways to manage scope and complexity of the code so I'm learning about features of JS.

Ответить
@fatemeetsluck
@fatemeetsluck - 26.12.2020 06:57

This helped me understand how to implement OOP in my own JavaScript interpreter.

Ответить
@SergeyNeskhodovskiy
@SergeyNeskhodovskiy - 22.08.2021 13:10

Of all the videos I was skimming through to finally wrap my mind around this subject, this one was my "aha!" moment. Thank you for the brilliant explanation!

Ответить
@4lm0std0n3
@4lm0std0n3 - 28.12.2021 06:33

thank you for this video

Ответить
@finwwwfinwww4669
@finwwwfinwww4669 - 25.07.2022 05:50

Thanks , it was short & simple and easy to understand

Ответить
@jndacademy
@jndacademy - 23.08.2022 23:31

Yup, I remembered why i hate JS.

Ответить