Тёмный

Javascript Interview Questions ( 'this' Keyword ) - Output Based, Scope, Implicit Binding, etc 

RoadsideCoder
Подписаться 107 тыс.
Просмотров 74 тыс.
50% 1

#JavascriptInterview #Javascript #FrontendInterview
Javascript Interview Questions on 'this' Keyword ( or Implicit Binding ) will be discussed in this video including how it behaves in global context, Function, Object etc.
🟦 Follow me on Twitter and u will clear your interview 🤓 -
/ piyush_eon
⭐ Support the channel and learn from me One on One -
/ @roadsidecoder
🔗 Blog for the video -
roadsidecoder.hashnode.dev/ja...
🔗 Functions Interview Video -
• Javascript Interview Q...
🔗 Objects Interview Video -
• Javascript Interview Q...
🔗 Javascript Interview Series -
• Javascript Interview Q...
🔗 Cars24 Interview Experience -
• Frontend Interview Exp...
🔗 Unacademy Interview Experience -
• Frontend Interview Exp...
🔗 MERN Stack Tutorial with Redux -
• MERN Stack Project Tut...
🔗 React Beginner's Project Tutorials -
• React JS Project Tutor...
-------------------------------------------------------------------------
00:00 Intro
01:00 What is 'this' ?
01:53 'this' in Global Context
02:30 'this' in normal function
03:08 'this' in arrow function
03:37 'this' in function inside Object
07:33 'this' in a class
09:26 Ques 1 - Output Based Question
10:35 Ques 2 - Result of accessing ref
12:41 Ques 3 - setTimeout and 'this' keyword
14:59 Ques 4 - Output Based Question
15:44 Ques 5 - Create a Calculator
17:24 Ques 6 - Output Based Question
20:15 Ques 7 - Implement 'calc' object
22:39 Call, Bind and Apply
-------------------------------------------------------------------------
Special Thanks to our members -
Srinivas Ayyagari
Saikiran K

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

 

26 июн 2024

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 171   
@RoadsideCoder
@RoadsideCoder 2 года назад
🔴 Get my Complete Frontend Interview Prep course - roadsidecoder.com/course-details
@Solo_playz
@Solo_playz Год назад
Hii brother can I get to know what's your age ??
@RoadsideCoder
@RoadsideCoder Год назад
@@Solo_playz 24
@Solo_playz
@Solo_playz Год назад
@@RoadsideCoder Great man are you an IITian
@RoadsideCoder
@RoadsideCoder Год назад
@@Solo_playz No, I'm from a tier 3 college
@Solo_playz
@Solo_playz Год назад
@@RoadsideCoder What is tier 3 ??
@harshdeepbilaiya3076
@harshdeepbilaiya3076 Год назад
this is some excellent practice material. pls add more o/p based Qs for OOJS, Prototypes, etc. an addition to the problem at 17:25 - if at line 4, we use let/ const instead of var to create 'length' variable, then while executing 'callback', the (this) Window object won't have length set to 4. It could be anything, like in JSFiddle, it is set to 0. since let/ const are created in TDZ. there can be so many more variations to this problem. i find this an incredible practice problem. many thanks!
@ivanshoshkov
@ivanshoshkov 2 года назад
I havent seen more detailed videos on coding subjects than yours! Thank you!
@RoadsideCoder
@RoadsideCoder 2 года назад
Haha, Thanks man!
@xen0076
@xen0076 Год назад
You are an absolute genius, i never understood this concept but your teaching is just fabulous, i hope that you launch your own udemy course in a structured way to master JS. You deserve to get paid for such content
@RoadsideCoder
@RoadsideCoder Год назад
Thanks a lot mate ❤️
@kalynndier6524
@kalynndier6524 Год назад
I absolutely LOVE your videos. You are amazing at explaining everything and for the first time EVER, I finally get it! Thank you. Do you have patreon? I'd love to support you.
@ismailshaikh1666
@ismailshaikh1666 3 месяца назад
This series is Onepiece of Javascript
@ninjaplavi
@ninjaplavi Год назад
I know it is a generalization, but many Indian devs seem to have issues with following naming best practices and I can't figure out why that is...On a more serious note, great videos, well structured and researched.
@de-stressmusic432
@de-stressmusic432 Год назад
This is because the whole video is a copy of an article by dmitripavlutin, my previous comment mentioning it was deleted.
@shrushtipolekar8804
@shrushtipolekar8804 2 года назад
Extremely helpful video! Helped me to develop a more clear understanding of 'this' keyword . Please keep on making more such output based questions videos.
@RoadsideCoder
@RoadsideCoder 2 года назад
Yes, So many more on the way!
@itsMohak
@itsMohak Год назад
You are splendid
@akshayshinde2403
@akshayshinde2403 Год назад
Question 6 & 7 are just mind blowing.
@ambeshtiwari9977
@ambeshtiwari9977 Месяц назад
thank you Roadside coder .
@bruhathimusicalwings1503
@bruhathimusicalwings1503 Год назад
gem of explanation ...thank you
@fares.abuali
@fares.abuali Год назад
Thank you so much! This is so informative 💖
@AmirHussain-dd6zw
@AmirHussain-dd6zw Год назад
You have great variety of questions
@kartik7775
@kartik7775 Год назад
Thank you so much! You're my favorite teacher.
@shubhamkharadkar3753
@shubhamkharadkar3753 19 дней назад
00:02 Understanding 'this' keyword in JavaScript 02:11 Understanding 'this' keyword in different contexts 04:14 Understanding 'this' keyword in JavaScript 06:32 Understanding 'this' keyword in normal function and arrow function 08:41 Understanding 'this' keyword in JavaScript object 10:37 Accessing 'this' inside a function can be tricky. 12:42 Understanding 'this' keyword in JavaScript 14:49 Understanding 'this' keyword in different functions 16:50 Understanding 'this' binding in JavaScript. 18:38 Understanding 'this' keyword in JavaScript functions 20:40 Example of chaining functions in JavaScript 22:32 Upcoming video on Explicit Binding
@AmolAghav
@AmolAghav Год назад
Question 5 was amazing! Thanks!
@shash0_0
@shash0_0 2 месяца назад
This is some really high quality content and all for free! Your curation of questions are impressive, really making me scratch my head. Thank you mate!
@RoadsideCoder
@RoadsideCoder Месяц назад
Thanks man! Full course here - roadsidecoder.com/course-details
@shash0_0
@shash0_0 Месяц назад
@@RoadsideCoder For sure. I'll buy your courses the first thing I get a job lol. Also do you have a patreon.
@vincent3542
@vincent3542 Год назад
Unbelievable video! I like all your Playlist about react and javascript... Love from indonesian 👍
@AkramDevTalks
@AkramDevTalks Год назад
Great explanation! A more accurate answer would be : In an arrow function "this" is a part of its closure, i.e. it is taken from the context. Where it is defined and not the object in which it is defined. In a normal function "this" is points to the object it is a part of.
@vinithaboyidi3354
@vinithaboyidi3354 11 месяцев назад
Great explanation!! Thanks
@DSEEUtkarshSinghParihar
@DSEEUtkarshSinghParihar 10 месяцев назад
THIS IS GOLD
@purusharma8192
@purusharma8192 Год назад
this channel is highly addicted,i have seen more than 10 videos continously
@RoadsideCoder
@RoadsideCoder Год назад
Hahah good to know ❤️
@purusharma8192
@purusharma8192 Год назад
@@RoadsideCoder you are awesome😎
@anubhapant5227
@anubhapant5227 4 месяца назад
Just learned so many new things from this video. The last ques is just amazing. Please make more such video of questions like the last one. Highly informative content 👌✌
@charankumarbasam5866
@charankumarbasam5866 Год назад
this with arrow function is greatly explained. thank you
@RoadsideCoder
@RoadsideCoder Год назад
Welcome ❤️
@abd11868
@abd11868 Год назад
14:08 piyush, can we do bind as well here? because I think once we bind a method with a object, no matter when/where we call that function it will always point to that object.
@simionandrei5409
@simionandrei5409 2 года назад
Great video! Are you going to drop some videos related to OOP Concepts(constructor, class) or Prototype Inheritance?
@RoadsideCoder
@RoadsideCoder 2 года назад
Yes, definitely if more people ask for it!
@manojradharapu4688
@manojradharapu4688 2 года назад
@@RoadsideCoder pls do it , then more people will watch and subscribe like me
@techupdate03
@techupdate03 2 года назад
@@RoadsideCoder yes sir..I also interested. After that can you explain about promise from scratch.
@kalyanyadlapalli6103
@kalyanyadlapalli6103 2 года назад
@@RoadsideCoder yes please drop a video brother
@ashwaniagrawal700
@ashwaniagrawal700 Год назад
@@RoadsideCoder yes, need some good videos on OOP concepts
@MukeshKumar-bt5gb
@MukeshKumar-bt5gb 2 года назад
Thanks, Was waiting for this! I was asked many questions regarding this in Cars24 interview this week 😄
@RoadsideCoder
@RoadsideCoder 2 года назад
Oh great
@ProgrammingWithProject
@ProgrammingWithProject 2 года назад
Please continue this series
@shubhamkakad10x
@shubhamkakad10x 9 дней назад
thank you because of you I understand this
@RoadsideCoder
@RoadsideCoder 8 дней назад
Thanks, u can check the complete course here - roadsidecoder.com/course-details
@ankushladani496
@ankushladani496 Год назад
Yes we want video on class,new keyword , etc....
@front-end-world
@front-end-world 2 месяца назад
I was recently asked a question on what is the difference between invoking the object directly suing the method & using call I did not know this implicit bindings vs explicit binding Great one kudos piyush :)
@lifeisbeautifu1
@lifeisbeautifu1 Год назад
Thank you
@himanshupandey3451
@himanshupandey3451 Год назад
on 17:56 the same code run on browser and node console return different result. on node console it return undefined?
@navneet8638
@navneet8638 Год назад
Bhai Apka Knowledge toh kamal ka hai🖤🖤🖤
@RoadsideCoder
@RoadsideCoder Год назад
🙏❤️
@SonuKumar-tw1oi
@SonuKumar-tw1oi Год назад
Please make a video on class , and its relation with this...Your content and teaching is fabulous.
@RahulKumar-ew1qw
@RahulKumar-ew1qw 2 года назад
Bro u make me great than my yesterday. Thank you ...
@RoadsideCoder
@RoadsideCoder 2 года назад
Great to hear that brother!
@pushpabhandari619
@pushpabhandari619 2 года назад
Helpful!! , thank you ❤
@RoadsideCoder
@RoadsideCoder 2 года назад
Welcome!
@riturathinsharma5931
@riturathinsharma5931 Год назад
This always sounds confusing. Just the easiest way to interpret. Its always the caller function for the normal function calls and for the arrow functions it will always be 2 level deeper( kind of like parent of parent)
@imtiazalikhan2709
@imtiazalikhan2709 2 года назад
Bro, your output based questions are Awsome.👋
@RoadsideCoder
@RoadsideCoder 2 года назад
Thanks dude!
@chiragsheth2263
@chiragsheth2263 Год назад
13:50 logs name when we use parenthesis in front logMessage method invocation.... Or if you set user property using let keyword
@nishachapte7
@nishachapte7 2 года назад
Thank you so much..amazing content.
@RoadsideCoder
@RoadsideCoder 2 года назад
Most welcome!
@BCSBhaveekJain
@BCSBhaveekJain 10 месяцев назад
At 14:50 we can do "setTimeout(user.logMessage(), 1000);", its giving correct output. We can do this also " setTimeout(user.logMessage.bind(user), 1000);"
@deepakverma2071
@deepakverma2071 2 года назад
Great video bro! Keep coming up with interesting videos like these ❤️. Just adding one more concept here Arguments in a function is not an array it is array like object. Array like object does not have all the properties of an array like map, filter etc.
@RoadsideCoder
@RoadsideCoder 2 года назад
Thanks for this important detail
@varunparihar3717
@varunparihar3717 4 месяца назад
this was great..can you please make videos on node,express,mongo too. That would be extremely helpful since you explain things quite nicely.
@rahulvanave
@rahulvanave 2 года назад
Yes Please make video on class as well
@angryman9333
@angryman9333 Год назад
I love this
@sidhishkumar
@sidhishkumar 2 года назад
yes Please create a deep tutorial on class and constructor
@DevangPatil
@DevangPatil 2 года назад
Nice.
@dharmeshgohil9375
@dharmeshgohil9375 2 года назад
Awesome👍👍👍
@RoadsideCoder
@RoadsideCoder 2 года назад
Thank you! Cheers!
@shreymaurya3344
@shreymaurya3344 2 года назад
Amazing Video🥳
@RoadsideCoder
@RoadsideCoder 2 года назад
🙏❤️
@tpadma7419
@tpadma7419 2 месяца назад
yes please make a video on constructors and this🙏
@RoadsideCoder
@RoadsideCoder 2 месяца назад
You can find this and other topics here - roadsidecoder.com/course-details
@tharapearlly1736
@tharapearlly1736 Год назад
Have you come across any practice sites that help us sharpen these skills?
@abhishekvishwakarma9045
@abhishekvishwakarma9045 2 года назад
fact is `this` is the least thing we will ever gonna use (class based is exception) in our day to day work, this makes this concept tougher but interviewers love this type of question lol😆, btw Awesome video 🔥
@RoadsideCoder
@RoadsideCoder 2 года назад
That's not true, if your company is using let's say class based component in react, it will use 'this' a lot
@abhishekvishwakarma9045
@abhishekvishwakarma9045 2 года назад
@@RoadsideCoder Completely agree forget about class based ✌but we're shifting towards functional based programming 😌
@parmarhitendrasinh4504
@parmarhitendrasinh4504 2 года назад
Amazing Video's ♥️
@RoadsideCoder
@RoadsideCoder 2 года назад
Thanks dude
@jayantsharma2669
@jayantsharma2669 2 года назад
Hey Piyush, thanks for this awesome video. Please correct my understanding if I am wrong: print is defined inside obj and obj don’t have its own scope its inheriting the scope from its parent which is global object that’s why arrow function pointing to global object (bcz it inherits this from lexical scope) . let obj = { name : 'temp', print : () => { console.log(this); // global/window object } }
@RoadsideCoder
@RoadsideCoder 2 года назад
It doesn't matter what scope obj has, arrow function takes its scope from parent normal function which in this case is not there, so it is targeting global. So even if the arrow function nested deep inside a object, if it doesn't have a parent normal function, it act the same.
@jayantsharma2669
@jayantsharma2669 2 года назад
@@RoadsideCoder Ok got it, arrow function search for nearest regular function that encloses it but in this case its not enclosed by any regular function then global this is inherited by arrow function.
@RoadsideCoder
@RoadsideCoder 2 года назад
@@jayantsharma2669 Yes!
@mohininarwade1108
@mohininarwade1108 Год назад
Hi Dear… I am really a big fan… You have such a deep knowledge of almost every technology. I have 1 request… Do you have any idea about how can we call salesforce commerce cloud API from Angular??? please reply if you know this or make a short video. Thanks
@Saikumar-kb4lf
@Saikumar-kb4lf 2 года назад
This is really good content. I can't deny that. But definitely here 'this' was explained in a hacky way. Please watch this related video from dev sage and you can really master this
@RoadsideCoder
@RoadsideCoder 2 года назад
Thanks, The main aim of this video is to assist for Javascript Interviews, therefore the hacky way.
@krunaljoshi7390
@krunaljoshi7390 8 месяцев назад
Really good content, make some practice platform
@hellochenyu
@hellochenyu 11 месяцев назад
Can you please help expain in 18:02? Why the nested fn() is targeted the global window object? Thanks!
@RoadsideCoder
@RoadsideCoder 11 месяцев назад
watch my functions video, u will understand it
@parmaryash4406
@parmaryash4406 2 года назад
Supep video
@RoadsideCoder
@RoadsideCoder 2 года назад
🙏
@acchugowda7767
@acchugowda7767 2 года назад
Please release next vedio on bindings as soon as possible.
@vishaltp6083
@vishaltp6083 2 года назад
hey , where can we find these kind of other questions
@anejasahil
@anejasahil 2 года назад
Dude just got introduced to your channela few days back your content is amazing, keep going man!!
@RoadsideCoder
@RoadsideCoder 2 года назад
Welcome aboard! And thanks a lot. ❤️
@harshsinghchauhan869
@harshsinghchauhan869 Год назад
🌟🌟🌟🔥
@user-nl4cr7tg3i
@user-nl4cr7tg3i 9 месяцев назад
Please make a video on session and local storage with Json.stringify , parse , constructors and classes also.
@divasbhadani9225
@divasbhadani9225 7 месяцев назад
where we can practice all those types of question ?
@user-np8rc1jw6n
@user-np8rc1jw6n 6 месяцев назад
Can you add interview series for Angular ? It will be really helpful for us as angular developer.
@mohitarya5189
@mohitarya5189 Год назад
Hello can anyone tell me where I can get the javascript output based questions
@RavindraSingh-lp9pl
@RavindraSingh-lp9pl 3 месяца назад
please make video on class and constructor in Javascript
@ooomr.kibeautifulmiss2754
@ooomr.kibeautifulmiss2754 Год назад
Make video for everything in javaScript ..
@ShivamSingh-ct1ix
@ShivamSingh-ct1ix Год назад
Hello Can you make a video on OOPS concept in javascript.
@abhirocks723
@abhirocks723 2 месяца назад
Hey guys .. can anyone explain why window.ref.name is not undefined and it is empty?
@sequoiakanies2202
@sequoiakanies2202 18 дней назад
Great video as always. Btw you are saying and spelling “substract” instead of “subtract”
@avinaymishra8345
@avinaymishra8345 Год назад
please make oops concept on javascript in details
@shubhanshusahuu
@shubhanshusahuu Месяц назад
Why calling user.method() inside console.log is not called as callback??
@0Ipsita0
@0Ipsita0 Год назад
Make video on class, constructors video please, i don't understand those
@sanjaychoudhury1266
@sanjaychoudhury1266 5 месяцев назад
this.a=7; function test(){ console.log(this.a); } test() result is showing undefined
@divyasampath2843
@divyasampath2843 Год назад
Video on class and constructors please!!
@RoadsideCoder
@RoadsideCoder Год назад
Soon!
@ProgrammingWithProject
@ProgrammingWithProject 2 года назад
Please tell the references point from where you learned all the core concepts of javascript
@RoadsideCoder
@RoadsideCoder 2 года назад
mdn docs
@dharmeshgohil9375
@dharmeshgohil9375 2 года назад
can you make a video of stripe payment plzzzzzzzzzzzz in hindi
@ayushyadav8851
@ayushyadav8851 Год назад
The day this video got published i was asked the calc question and i messed up because of 'this' reference
@PIYUSH-lz1zq
@PIYUSH-lz1zq 2 года назад
sir , can u make videos to make nested comment section and folder structure using JS
@RoadsideCoder
@RoadsideCoder 2 года назад
Sure, Noted!
@s1k_guy
@s1k_guy 2 года назад
Bro why dont you create javascript vedios on basic data structure algorithm so it will help in interviews.
@RoadsideCoder
@RoadsideCoder 2 года назад
Yes I have planning that, coming soon!
@hemamane739
@hemamane739 Год назад
let user = { name :"hema mane!", getName(){ console.log(this.name) } } let data =setTimeout( user.getName() ,1000) console.log(data) console.log(data) ---> is it correct way of accessing or else mandetory to use inside function only
@techycode2217
@techycode2217 3 месяца назад
So What' difference if you upload same video in your paid course and and youtube ?
@RoadsideCoder
@RoadsideCoder 3 месяца назад
Here's your answer - www.linkedin.com/feed/update/urn:li:activity:7174019126041018370/?originTrackingId=GTshFzTMQBqFiLZrQQuBNw%3D%3D
@mohdraqim2571
@mohdraqim2571 Год назад
var length =4; function callback(){ console.log(this.length); } const object ={ length :5, method(fn){ fn(); }, }; object.method(callback); it giving undefined instead of output 4 anyone?
@brakesh1273
@brakesh1273 Год назад
Ya facing the same issue
@ammanmoini1202
@ammanmoini1202 Год назад
sir what is window object and global object? plz explain a bit..
@RoadsideCoder
@RoadsideCoder Год назад
Hey, you can refer to this - developer.mozilla.org/en-US/docs/Web/API/Window
@arvindverma2629
@arvindverma2629 Год назад
make a video class and constructor
@rohithchittibommala2002
@rohithchittibommala2002 2 года назад
Live stream + resume review
@PIYUSH-lz1zq
@PIYUSH-lz1zq 2 года назад
bhaiya , make a small js project which consist of these js concepts of debouncing , throttling etc.. placements r comming
@RoadsideCoder
@RoadsideCoder 2 года назад
Ok bro, noted!
@sajalgupta7345
@sajalgupta7345 2 года назад
My solution for Question 2: function user() { return { name: "Sajal", ref: this } } const test = user(); const result = user.bind(test); console.log(result().ref.name); //Sajal I tried it with .bind() 😀
@RoadsideCoder
@RoadsideCoder 2 года назад
Good job!
@ketandutt
@ketandutt Год назад
Q3. it should be setTimeout(user.logMassage(), 1000) //() missing
@Lucifer-xt7un
@Lucifer-xt7un 2 года назад
Where are you working now bro
@darshillashkari6384
@darshillashkari6384 Год назад
put dsa and oop vids on javascript
@mastpahadan490
@mastpahadan490 2 года назад
you go boy!!!!❤️❤️
@RoadsideCoder
@RoadsideCoder 2 года назад
🙏❤️
@bluevojka
@bluevojka 3 месяца назад
Hi, can anyone please explain 18:01
@anuragsharma966
@anuragsharma966 2 года назад
Where to get all these questions?
@samyakjain9850
@samyakjain9850 2 года назад
All questions are from here dmitripavlutin.com/javascript-this-interview-questions/
@anuragsharma966
@anuragsharma966 2 года назад
@@samyakjain9850 thanks man
@tricyclejesus4572
@tricyclejesus4572 Год назад
You should title these videos "JS trick questions". Seriously, if an interviewer was to ask these sorts of questions I'd politely excuse myself and look elsewhere.
@igorr4682
@igorr4682 9 месяцев назад
what's more confusing to me is What's on your Head ??
@RoadsideCoder
@RoadsideCoder 9 месяцев назад
Where I'm from, Its called hair👀
Далее
THEY WANTED TO TAKE ALL HIS GOODIES 🍫🥤🍟😂
00:17