Тёмный
No video :(

Javascript Literals, Functions, and Constructors 

Source Decoded
Подписаться 15 тыс.
Просмотров 30 тыс.
50% 1

In this, our 2nd episode, we go over Javascript's object Literals, then some of the Function's magical properties, like scope, context, and the "this" and "arguments" keywords. Finally, we discuss constructors, and what the "new" keyword is actually doing under the hood.

Опубликовано:

 

28 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 55   
@tvsa7
@tvsa7 6 лет назад
6:32 that dude predicted arrow function, well done :D
@andriyosipov8165
@andriyosipov8165 4 года назад
was the arrow function implemented after Jan 31 2014 into JS and he actually predicted it or this was a joke?
@katyasorok9536
@katyasorok9536 6 лет назад
Thank you for teaching with immediate thinking process. It allows the listener to process the information as an active thinker. This innovative method is very hard to find and it is far superior to just lectures or demonstrations.
@thebuildguy7
@thebuildguy7 4 года назад
I thought of it for a long time and all I could think of saying you guys is, Thank You! 🎉 I hope you keep this channel alive 🤗
@shinyeeh
@shinyeeh 9 лет назад
Best JS youtube video!!! Thank you guys!
@JoshuaWhiteSierra973
@JoshuaWhiteSierra973 8 лет назад
You guys are great!! Watching your videos has not only been helpful but also a pleasure. Please continue making great videos for all of us!!!!
@iamfrankstallone
@iamfrankstallone 10 лет назад
FYI you guys are brilliant and compliment each other really well. I can only imagine how much fun this would be to do with liked minds. I cannot thank you enough for your patience, and only wish there were more drawing/visual interpretations like the first video! =P
@mikeputz5320
@mikeputz5320 7 лет назад
Just my opinion, but episode 1 was my favorite. Giving eachother solo time on the whiteboard. Asking questions viewers might have. Then expounding when you trade off. I appreciate the work you put in. I have to learn JS quick for work and this was a big help.
@azhax6127m
@azhax6127m 6 лет назад
agree
@AlbertoVasquez1
@AlbertoVasquez1 8 лет назад
When you were listing the Constructor / Literals they kept on mentioned that the two sides are equal. Don't be confused, they are only equal if you don't add the new keyword. If you use the non constructor context, with the new, it returns a literal. So String('a') really is equal to 'a' but new String('a') is not the same thing as 'a'.
@yana7j
@yana7j 4 года назад
that was so interesting to watch! Even I start to understand something! You guys are great! Thnks!
@k.7126
@k.7126 7 лет назад
I came in watching the middle & ending episodes first. But, though I'm a newbie, I'm daily consuming this stuff/shoving it into my brain. At first, I was not sure about you, but something about your quirkiness kept me watching. I like your quirkiness because some how it relates to some of my confusion, & your conversational interactions w/each other -- the mental walk throughs -- have been helpful. Thanks. Now off to reviewing (again) your "Oops, everything is not an Object). Then I'll finish w/your first episode. :)
@steinmil
@steinmil 10 лет назад
Great video guys. I'm just learning the language and you explain it really good. Very good discussion.
@mouhyemenkhan2295
@mouhyemenkhan2295 9 лет назад
You guys are super interesting!
@SpencerCornelia
@SpencerCornelia 9 лет назад
Thank your for this thorough video.
@nabazgharib
@nabazgharib 9 лет назад
These guys are AWESOME... Thanks, now I know what the factory is...... What the object is... AVERY BIG THANKS....
@kianrafi3048
@kianrafi3048 6 лет назад
Now I get it all!
@matthewmoon2463
@matthewmoon2463 9 лет назад
Correct me if I'm wrong but although the script may compile if you call a function before you define it, certain browsers will choke on it. Firefox is one that won't hoist the function if it's called in a 'for' or 'if' block.
@SargsyanGagik
@SargsyanGagik 9 лет назад
Pair teaching :)
@tanish2204-p9o
@tanish2204-p9o 5 лет назад
Thank you for making these videos guys.. Can anyone recommend a sequence to follow the videos in this playlist?
@maudaertsen994
@maudaertsen994 9 лет назад
Awesome!
@bamba2514
@bamba2514 9 лет назад
you guys are awesome!
@lukusacrispin950
@lukusacrispin950 7 лет назад
you guys are awesome! can you please try to numbered the tutorials so that we can know where to start
@Savios-EcoExplorations
@Savios-EcoExplorations Месяц назад
JS my best language 🥰
@agentsmidt3209
@agentsmidt3209 8 лет назад
I could by you guys beer (assuming that you drink), by you are too far away from where I am. Thanks again
@_origin5858
@_origin5858 6 лет назад
when i create an object is there any primitive class that my object inherit from it ?
@terrygilliver8404
@terrygilliver8404 9 лет назад
I thought that this was about javaScript is easy, on 3rd video, and I think you will be scaring off most beginners
@andriyosipov8165
@andriyosipov8165 4 года назад
Here it is: on 7:57 from 50:02 total length I can state "All that glitters is not gold".
@TylerLemke
@TylerLemke 6 лет назад
At 6:43, its stated that the new is the same as the literal. This is not the case. See developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String. That is why the gotcha exists. Great job overall with this video, though! I hope to keep my videos as engaging that I make!.
@manwize07
@manwize07 9 лет назад
Another way to write a function that is self-invoking. It calls itself immediately. (function () { var x = "Hello!!"; // I will invoke myself })(); // Anonymous var hello = (function () { var x = "Hello!!"; // I will invoke myself })(); // Same as above function but the name hello is for debugging
@raj-hg7yd
@raj-hg7yd 8 лет назад
i love you both!
@msms3260
@msms3260 3 года назад
Lost at 35:00. Maybe I am in the wrong video order-wise after the watching the first two.
@azhax6127m
@azhax6127m 6 лет назад
unfortunately after the first video i don't understand the contend can't follow. First video was awesome but now for me its like you guys taking about some staff that you already know but me like what's going on! :(
@chrisb715
@chrisb715 8 лет назад
Steve Jobs and Bill Gates hahahahaha. Great video guys.
@w_ulf
@w_ulf 10 лет назад
Thoughts? tech.pro/tutorial/1953/functional-javascript-part-1-introduction
@sourcedecoded2337
@sourcedecoded2337 10 лет назад
That article is great! Take a look at these videos. channel9.msdn.com/Tags/erik+meijer I have spent days watching Erik's videos about functional programming. Most of his videos are high level, not language specific, which is great because you can apply the knowledge to any functional language of your choice. Erik makes you think deeply about things, and that is what I like. :)
@w_ulf
@w_ulf 10 лет назад
Thanks again. With your help, I'll be well on my way to becoming a JavaScript Jedi Master!
@michaelcatalano8724
@michaelcatalano8724 9 лет назад
I once knew a kid named Jason. is this the Jason u were talking about? lol
@asmartbajan
@asmartbajan 6 лет назад
No, they were referring to July August September October November.
@terrygilliver8404
@terrygilliver8404 9 лет назад
have you mentioned comments yet, you are using // quite often without explaining that this is a code comment
@AinurEru
@AinurEru 10 лет назад
If I understand JavaScript correctly, you were not entirely accurate with that last example, and in very subtle - but profound - kind of way: When you are using the "this" keyword inside a constructor, and adding capabilities onto it, you are NOT doing the same thing as you did when adding that same functionality to the prototype of that constructor. In the "this" case, you are adding the functionality to each "instance" independently, whereas in the prototype-way you are only adding it to a single-object - the prototype. This is very important (IMHO) to explain, because if you later change something to the behavior "After" some cars have been instantiated, then in the prototype-way, you would only have to change in one place and that would affect all the cars that were already created, whereas in the "this"-way, if you override the constructor, you would NOT retroactively change all existing cars, only new ones created after the change. If you wanted to change the cars already created, you would have to go through each of them one by one and change them... And in most real-world scenarios that would probably not even be possible, as you don't necessarily control all the instances... Plus, if you make a million cars, then the "this" -way would take up a million times more memory then the prototype-way, because you would have the same functionality duplicated and dangling off-of each of the million cars...
@sourcedecoded2337
@sourcedecoded2337 10 лет назад
I see what you are saying, and you are right: what is done in the constructor function (or factory) using "this" belongs to the individual instance. Things done to the prototype are done to all instances. In our last example, this.running, this.start, and this.stop will be specific to an instance. If we had put those things on the prototype, all instances of a Car would have those properties, but they would all share the /same/ properties, meaning if you started one car, they'd all be running. We did it the "this" way, because we want to just start one of them at a time. As you point out, if you changed the constructor function to do different things to "this" at some point in run-time, only the instances created after the change would reflect it.
@AinurEru
@AinurEru 10 лет назад
Well, there is a distinction between "prototype-level attributes" vs. "prototype-level functions", and between "instance-level attributes" vs. "instance-level functions". But you can do combinations, so, for example, If you say you want to be able to keep the start/stop/running-state of each instance, that's obvious, but it only means you would want to keep the "stage-attribute" as "instance-level" - It doesn't mean you have to keep the start/stop-functions as instance-level as well - theses should be prototype-level, and would still work on a per-instance-state whenever they are called on one, because JavaScript does instance-binding of public-methods at "invocation-time", and not before that. So, even if you have the start/stop functions on the prototype, it would still bind them to each instance's running-state, on each time you call the methods on one. This way you get the best of both worlds - you only keep instance-level state of the things you absolutely have to, and keep the rest on the prototype. You would not be saving memory for the state (but you really can't do that anyway while keeping them separate), but you WILL be saving tons of memory for not duplicating all of the function-objects for each instance (I hope I was clear enough...)
@AinurEru
@AinurEru 10 лет назад
Another thing I think you should mention, is how this kind of optimization-decision is circumstantial - this goes to "Good Software-Engineering". You want your viewers to learn how to think like good software-engineers, and not just good-coders... So, whenever there are trade-off to be made, they should understand where to apply what trade-off, and for what reasons. In this case, we are talking about memory-consumption vs. computation. Attribute-access on an instance is much faster then attribute-look-up through a prototype-tree. So, if you have an extremely deeply-nested hierarchy of prototypes, but only a few instances, if might actually be better to keep things on the instances, as you don't have much to gain in terms of memory, but have a lot to gain in performance if you do so. In contrast, if you have a very shallow-prototype-chain, but thousands of objects, then the performance-cost of traversing the prototypical-chain is negligible, but the potential-benefits of memory-savings are huge. If people understand the trade-off, and where to apply which-one, it makes them better software-developers, and not just "code-writers" (That's how I see it...). Perhaps you should make another short episode on this? :)
@AinurEru
@AinurEru 10 лет назад
Here is the best explanation I know of of prototypes in js: sporto.github.io/blog/2013/02/22/a-plain-english-guide-to-javascript-prototypes/
@connor43057
@connor43057 8 лет назад
+Source Decoded one nice way to add new properties to all cars, yet maintaining individual control is to push all cars into an array and then reference their functions using indexes. That way you get the efficiency benefits of using prototype and then array indexes provide the same local contexts as the this keyword does :)
@137rsabir
@137rsabir 4 года назад
The guy on the right only confuses a lot.
@joshiranjana
@joshiranjana 8 лет назад
Ever herd of too many cook spoil the food, you guys are two too many in the screen. Probably only one person should teach. Personally I think Benjamin is the best at teaching you guys should let him teach and please don't interfere him.
@KP-sl8nf
@KP-sl8nf 7 лет назад
Ranjana Tiwari Ever heard of " Heard" .... that's how it's written
@justind6983
@justind6983 6 лет назад
Two years later and I just wanted to say I disagree.
@msms3260
@msms3260 3 года назад
They both bring great value and are needed.
@yeeli7989
@yeeli7989 5 лет назад
Shorter guy keeps trying to take the spotlight from the taller dude. Why cant the shorter guy stop acting like an arrogant and let his coworker do the teaching.
Далее
In Javascript, Everything Is (or acts like) An Object
36:50
Ajdarlar...😅 QVZ 2024
00:39
Просмотров 619 тыс.
I Love *&@^#! JavaScript!
27:06
Просмотров 11 тыс.
Javascript is Easy Part 2
22:37
Просмотров 43 тыс.
Douglas Crockford: The JavaScript Programming Language
1:49:55
JavaScript Scope Chains and Closures
56:24
Просмотров 46 тыс.
Javascript is Easy
48:36
Просмотров 376 тыс.
JavaScript Higher Order Functions & Arrays
34:56
Просмотров 983 тыс.
The Observer Pattern
43:37
Просмотров 11 тыс.