THIS keyword - Beau teaches JavaScript

  Рет қаралды 57,726

freeCodeCamp.org

freeCodeCamp.org

7 жыл бұрын

The 'this' keyword refers to the object that "owns" the JavaScript code.
💻 Code: codepen.io/beaucarnes/pen/GWPO...
🔗 Resources: developer.mozilla.org/en-US/d...
codepen.io/somethingkindawier...
🐦 Beau Carnes on Twitter: / carnesbeau
⭐JavaScript Tutorials Playlists⭐
▶JavaScript Basics: • JavaScript Basics Course
▶Data Structures and Algorithms: • Data Structures and Al...
▶Design Patterns: • Design Patterns - Beau...
▶ES6: • ES6 - Beau teaches Jav...
▶Clean Code: • Clean Code - Beau teac...
-
We're busy people who learn to code, then practice by building projects for nonprofits. Learn Full-stack JavaScript, build a portfolio, and get great references with our open source community.
Join our community at freecodecamp.com
Read great tech articles at medium.freecodecamp.com

Пікірлер: 73
@raywillaimjhonson
@raywillaimjhonson 4 жыл бұрын
The more I try to understand "this" the more my brain wants to fall out of my head.
@BobbyBundlez
@BobbyBundlez 3 жыл бұрын
hope u figured it out. im like 75% there haha
@S4LTYT
@S4LTYT 3 жыл бұрын
same
@midknight3350
@midknight3350 Жыл бұрын
Ditto. I'm having a hard time picking it up.
@user-yq7ip3jy3r
@user-yq7ip3jy3r 3 ай бұрын
Same , like whats is good for? !LOL
@grandpowr
@grandpowr 6 жыл бұрын
I understood because I read the book You Don't Know Javascript, but I think you should slow down a bit for newer people, otherwise I found it well made, really love this series you're doing.
@masterwayne9790
@masterwayne9790 3 жыл бұрын
Thank you it helped me in others ways too
@user-yq7ip3jy3r
@user-yq7ip3jy3r 3 ай бұрын
agreed too many hard codes that u even forgot the lesson that u should understand!
@GabeDStudios
@GabeDStudios 8 ай бұрын
Let me re-arrange some sections to make it a bit clearer and beginner friendly: var o = {a: 1, b: 3}; function add(c, d) { return this.a + this.b + c + d; } console.log(add.call(o, 5, 7)); console.log(add.apply(o, [10, 20])); It's good practice to declare all your variables and values first before any functions and by doing this, it becomes easier to read. Here we create an object with two properties which is "a and b". "a" set to 1 and "b" set to 3. "this.a" and "this.b" is pointing to the properties of the variable "o". apply and call are METHODS for the "this" keyword, think of them as attachments for your gun that enables it to do other stuff. the rest should be self explanatory if you studied the basics well. If not, gotta go back to start, you might have missed a few lessons.
@GraceandWisdom
@GraceandWisdom 3 жыл бұрын
I really would like to grasp these concepts, but it seems as though JavaScript is some sort of 'bottomless pit' of information that cannot be explained in a simplistic terminology. Thereby leaving a beginner unsure about what one learns.
@abdelkrimeljaouhari2370
@abdelkrimeljaouhari2370 4 жыл бұрын
You have not simplified the issue ,but thank you for the video
@novanoskillz4151
@novanoskillz4151 2 жыл бұрын
this has to be the least beginner friendly tutorial on the subject. I feel like I have to be a brain surgeon to follow along.
@thomascarlton82
@thomascarlton82 2 жыл бұрын
Yeah this. is a terrible video. I thought the point of these types of videos was to teach to people that dont already understand it. Seems like a lot of programming videos are for people that already know the stuff and want to watch someone else do it too
@doublesushi5990
@doublesushi5990 Жыл бұрын
@@thomascarlton82 indeed.
@curiousindividual634
@curiousindividual634 4 жыл бұрын
you haven't answered the main question: Why TF do we need "this" in the first place? It does absolutely nothing. Is it some sort of inside joke?
@thomascarlton82
@thomascarlton82 2 жыл бұрын
This video is funny, for people that don't know what this is. It's does nothing to help us but for those that understand it, they are saying its a great video. Lmao this is dumb
@ww4102
@ww4102 4 жыл бұрын
If you listen very carefully, the first 14 seconds explain a lot! " The value of 'this' when used in a function, is the object that owns the function"
@oufcena5092
@oufcena5092 4 жыл бұрын
The keyword this is just a place holder for the object it's been called upon so, this.prop = o.prop;
@VanHaleNNoodle
@VanHaleNNoodle 2 жыл бұрын
When Beau says 'Created' about O (When talking about arrow functions around minute 7), does created mean when it is first called ? Intuatively, I would have thought, it was created in the O object.
@core_dump
@core_dump 6 жыл бұрын
Great info! Understanding core JavaScript is so important... its more important than learning frameworks.
@manas_singh
@manas_singh 5 жыл бұрын
Excellent explanation, I loved it
@Azar211
@Azar211 3 жыл бұрын
Many thanks for this serious video about the subject far away from the "hello world" ones , one should be concentrated , stop and replay to get the best of the video , thank you again
@markodjuric3905
@markodjuric3905 6 жыл бұрын
Thanks for this!
@beccaarauz
@beccaarauz 6 жыл бұрын
for someone who's starting in JS this video was very fast, I find it a little hard to understand.
@heatherbeckman1767
@heatherbeckman1767 4 жыл бұрын
I've been studying JavaScript vigorously for the last 4 months, I don't know if it's necessarily the video that is making it confusing or the complexity of the subject matter itself. I've been reading resources and have watched several videos and still haven't quite grasped "this." I just noticed that your comment was from a year ago, so if you kept up with your JS journey you are probably more advance than me. Did you ever find a better resource for "this" or can you explain it better?
@oufcena5092
@oufcena5092 4 жыл бұрын
@@heatherbeckman1767 The keyword this is just a place holder for the object it's been called upon so, this.prop = o.prop;
@heatherbeckman1767
@heatherbeckman1767 4 жыл бұрын
@@oufcena5092 Thanks. This is actually quite helpful.
@mrsoccer9449
@mrsoccer9449 3 жыл бұрын
@@oufcena5092 Now that make sense
@c0mpuipf
@c0mpuipf 7 жыл бұрын
great stuff beau just a question - I read that if you have a method within an object and inside that object you've got 2 functions, the second function will lose the this context and will refer to the global object (the var that = this shtick)
@BeauCarnes
@BeauCarnes 7 жыл бұрын
You may be thinking of callbacks. I think that is what happens when one function calls another after it finishes.
@christianrodier3381
@christianrodier3381 6 жыл бұрын
This is very helpful thanks
@threeone6012
@threeone6012 6 жыл бұрын
Great upload!
@rmb1831
@rmb1831 6 жыл бұрын
Complicated example. Must use easy to understand parameters.
@gabrielsoloman5000
@gabrielsoloman5000 4 жыл бұрын
great lesson!
@freyjaaldebaran7275
@freyjaaldebaran7275 Жыл бұрын
Lmao i thought i had understood but then i read the comments and obviously i didn´t understand
@AwB
@AwB 7 жыл бұрын
Great stuff
@mdabutalha3165
@mdabutalha3165 5 жыл бұрын
short time best explanation.
@DomedIsDoomed
@DomedIsDoomed Жыл бұрын
Loving this video
@Andrei-xb1pz
@Andrei-xb1pz 4 жыл бұрын
Yes it was fast, but there is a pause button for that. Thanks for explaining THIS in its various contexts. It's not the definite guidebook, but it was very helpful to me!!!
@hashtagtrends9886
@hashtagtrends9886 3 жыл бұрын
Thank you!
@skepticbubble3166
@skepticbubble3166 5 жыл бұрын
Very neat explanation for 8:47 video thanks!
@nehagavali9416
@nehagavali9416 2 жыл бұрын
Which editior are you using
@Azim2562
@Azim2562 5 жыл бұрын
thanks
@Drachensingsang
@Drachensingsang 7 жыл бұрын
I think this video misses structure as well as the point: Why? How "this" is interpreted depends on when it gets "resolved" so to speak. If you would have explained why it gets when resolved, one wouldnt need to store all this empty knowledge in his/her brain but rather would understand the underlying concept, which is less amout of data and way more powerful.
@TheLoniard
@TheLoniard 4 жыл бұрын
Eureca! Thank you for this movie. I have got it!
@justinherrera6790
@justinherrera6790 5 жыл бұрын
too fast, too advance. your reference is mdn and I thought that this video will give me a best explanation but I was wrong
@redouanemahjoubi1914
@redouanemahjoubi1914 6 жыл бұрын
what program are u using ?
@oufcena5092
@oufcena5092 4 жыл бұрын
Why not bother to the description?
@gustavokuthumy404
@gustavokuthumy404 2 жыл бұрын
My head spinned the 1st time I watched, but I could I understand it in the 2nd run. Thanks!
@shankerm3959
@shankerm3959 6 жыл бұрын
Thank you, but you need to slow down much more. I kept getting lost and eventually stopped at the half-way point.
@namangupta1817
@namangupta1817 7 жыл бұрын
can anyone tell me why i am getting o.f() is undefined instead of value 8 ??
@BeauCarnes
@BeauCarnes 7 жыл бұрын
I'd have to see the rest of the code to know for sure. Maybe you could put it on codepen.io and share a link.
@namangupta1817
@namangupta1817 7 жыл бұрын
Thanks a lot for such a quick reply. Actually, i missed the f:f part in object declaration part .. that's why it was throwing an error that .. f is not a value associated with o . But now it has been resolved :D :D .. thanks a lot for this awesome series
@perfectigbadumhe113
@perfectigbadumhe113 4 жыл бұрын
Didn't understand sheet
@sevakk.939
@sevakk.939 2 жыл бұрын
great, great, great
@terrancekent7887
@terrancekent7887 6 жыл бұрын
Slow down & get a new mouse lol. But thanks for the help.
@nowyouknow2249
@nowyouknow2249 5 жыл бұрын
Bad way to teach. I had to stop the video halfway to avoid complications. Slow down and put the learner in mind next time.
@Beam28
@Beam28 7 жыл бұрын
Not the best explanation of "this". "You Don't Know JS" is where you need to read.
@jincypaul05
@jincypaul05 5 жыл бұрын
Can you share the link of "You Don't Know JS" ?
@justinherrera6790
@justinherrera6790 5 жыл бұрын
true
@inononeeee
@inononeeee Жыл бұрын
@stocktrade9655
@stocktrade9655 4 жыл бұрын
this tutorial is so confusing
@awekeningbro1207
@awekeningbro1207 4 жыл бұрын
This was confusing.
@irfansindhi5091
@irfansindhi5091 6 жыл бұрын
Just stop clicking
@Doda100creative
@Doda100creative 6 жыл бұрын
This video could save a whole day wasted in 8 minutes
@aalez1983
@aalez1983 3 жыл бұрын
those mouse clicks are so loud I had to stop 1 minute in the video because it's distracting from the subject
@KL4NNNN
@KL4NNNN 4 жыл бұрын
worst among the most incompetent people who tried to explain this.
@josemaribautista7552
@josemaribautista7552 4 жыл бұрын
thanks but i hate it
@ShoSidney
@ShoSidney 3 жыл бұрын
most confusing tutorial...
@ZooDinghy
@ZooDinghy 3 жыл бұрын
JavaScript is disgusting. Utterly disgusting!
@AgrabATC
@AgrabATC 4 жыл бұрын
Worse explanation ever! It confused me more.
Functions - Beau teaches JavaScript
7:18
freeCodeCamp.org
Рет қаралды 68 М.
What is THIS in JavaScript? in 100 seconds
6:38
Fireship
Рет қаралды 211 М.
UFC Vegas 93 : Алмабаев VS Джонсон
02:01
Setanta Sports UFC
Рет қаралды 174 М.
Они убрались очень быстро!
00:40
Аришнев
Рет қаралды 3,1 МЛН
Balloon Stepping Challenge: Barry Policeman Vs  Herobrine and His Friends
00:28
PINK STEERING STEERING CAR
00:31
Levsob
Рет қаралды 20 МЛН
Objects - Beau teaches JavaScript
8:40
freeCodeCamp.org
Рет қаралды 41 М.
JS "this" and Function References - What is it all about?
20:20
Ternary Operator - Beau teaches JavaScript
4:18
freeCodeCamp.org
Рет қаралды 54 М.
JavaScript "THIS" keyword in 1 Minute #shorts
1:00
ColorCode
Рет қаралды 145 М.
Copying Arrays (deep and shallow) - Beau teaches JavaScript
5:56
freeCodeCamp.org
Рет қаралды 45 М.
Immediately Invoked Function Expression - Beau teaches JavaScript
3:32
freeCodeCamp.org
Рет қаралды 68 М.
Common Array Methods - Beau teaches JavaScript
6:46
freeCodeCamp.org
Рет қаралды 64 М.
Visually Understanding JavaScript Prototypes
14:58
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 52 М.
AJAX - Beau teaches JavaScript
6:14
freeCodeCamp.org
Рет қаралды 37 М.
UFC Vegas 93 : Алмабаев VS Джонсон
02:01
Setanta Sports UFC
Рет қаралды 174 М.