Javascript Interview Questions ( Call, Bind and Apply ) - Polyfills, Output Based, Explicit Binding

preview_player
Показать описание
#JavascriptInterview #Javascript #FrontendInterview

Javascript Interview Questions on Call, Bind and Apply Methods ( or Explicit Binding ) will be discussed in this video including its in Polyfills, Output Based Questions, this keyword etc.

🟦 Follow me on Twitter and u will clear your interview 🤓 -

⭐ Support the channel and learn from me One on One -

🔗 Blog for the video -

🔗 "This" Keyword Interview Video -

🔗 Objects Interview Video -

🔗 Javascript Interview Series -

🔗 Cars24 Interview Experience -

🔗 Unacademy Interview Experience -

🔗 MERN Stack Tutorial with Redux -

🔗 React Beginner's Project Tutorials -

-------------------------------------------------------------------------

00:00 Intro
00:43 Ques 1 - What is Call?
02:54 Ques 2 - What is Apply?
03:38 Ques 3 - What is Bind?
04:53 Ques 4 - Output Based Question
06:10 Ques 5 - 'call' with function inside object
07:54 Ques 6 - Output Based Question
09:40 Ques 7 - Print all animals in Object
11:35 Ques 8 - Append Array with "apply"
13:30 Ques 9 - Using 'apply' to enhance built-in functions
14:59 Ques 10 - Bound Function
15:55 Ques 11 - Bind Chaining
16:48 Ques 12 - Fix the code
19:07 Ques 13 - Partial Application with bind
21:14 Ques 14 - Explicit Binding with Arrow Function
23:05 Ques 15 - Call Polyfill Implementation
26:54 Ques 16 - Apply Polyfill Implementation
28:18 Ques 17 - Bind Polyfill Implementation
32:14 Read Blog for this Video
32:23 Important Message 👀

-------------------------------------------------------------------------

Special Thanks to our members -
Srinivas Ayyagari
Saikiran K
Рекомендации по теме
Комментарии
Автор

Great Video 🤩, Yesterday a interviewer asked me to do a small function like this

const a = [1, 2, 3] // Output [1, 2, 3, 1, 2, 3]

I used spread method like this [...a, ...a]

Then he asked to do it in some other way, I could have used call and apply

a.push.call(a, ...a);
a.push.apply(a, a);

Thank you soo much for your hard work 😇🥰

ajitshaw
Автор

You can simpley destruct the array inside Math.max(...numbers) in order to get the same output. Apply isn't necessarily required but thanks for opening new doors, was helpful to understand a new usecase.

codeedict
Автор

one of the best videos I saw on the internet regarding polyfill for bind call and apply. Really really really thank you so much and god bless you, bro.

juniorWeb
Автор

When I executed the same code, (given below), I got the output as undefined. Please explain
var status = 1;
setTimeout(() => {
const status = 2;
const data = {
status: 3,
getStatus() {
return this.status;
},
};

}, 0);

sobhanthakur
Автор

Much needed video, especially wrt implementations using polyfills! Exanples and explanations on point 🚀

hamzahusein
Автор

Amazing explanation.
Just a little correction, in polyfills implementation for call and apply, I think we need to call and return the return value also i.e. return context.fn(...args).

prasangsinghal
Автор

Function.prototype.myCall = function(context = {}, ...args){
if(typeof this !== 'function'){
throw new Error(this + ' is not callable')
}
context[this.name] = this;
context[this.name](...args)
}
We can also make our context object function key as our function name by doing this.

hemangkoshiyar
Автор

At 15:40 sorry for pointing out but you did not clearly clarify why this would represent the global object here. The answer should be in non-strict mode javascript replace the `this` value to global object if it is assigned any value like null and undefined.

nidhisharma
Автор

Can you pls do a React specific interview questions, this is what lacks in all the best YouTube channels

kovendanragupathi
Автор

You deserve a subscribe. Keep up the good work bro.

prateekgupta
Автор

For pollyfill, can't we create call, apply and bind with Object protoype ?
According to your implementation, it will throw error if we attach these methods with object having a function.

ashishroshan
Автор

Could you please make those videos in hindi language. It will be very easy to us. Please please make videos in easy hindi language..

arijitroy
Автор

Polyfills understanding lot. How to think. Keep

karthikeyasoft
Автор

People who are having issues with polyfills just run this, you will get it.
Function.prototype.myCall=function(context, ...args){
console.log("this ", this);
console.log("context ", context);
console.log("args ", args);
context.func=this;
console.log("context1 ", context);
context.func(...args)
}

Rohitsingh
Автор

#22:38 in the window object we have age, why it is displaying undefined.

Normally

var age=10;
let sample={
age: 20,
getage: ()=>{
console.log(this.age);
}
}
sample.getage();
Output will be :10

I'm still in confusion 😃 why it is displayed undefined

var age=10;
let sample={
age: 20,
getage: ()=>{
console.log(this.age);
}
}

let sample2= {
age: 30
};

sample.getage.call(sample2)
o/p: 10

sunilkumar-zfdx
Автор

Bhaiya bht din video nhi ayi, how are you?
One Request bhaiya can u start react and next combined course which will cover basics to advanced with project also ? I was trying to learn, not able to focus what to learn

brajagopalmukherjee
Автор

In call polyfill what does context.fn = this; line represent

ShubhamJain-qxtv
Автор

Thank you for the video! I have a question about #14 for anyone. For the getAgeArrow function, why doesn't the 'this' keyword contain the context of const age = 10 as declared on line 4?

evangriffith
Автор

Hi Piyush, just one thing, in the polyfills, I think we shouldn't add our function directly to the context object as it manipulates the original object. We can clone the object and then call our context.fn()

Ashish-_-
Автор

Yes need video on prototypes of all objects.

Solo_playz