The main difference between regular and arrow functions is a context (this): regular function changes context (this = parent object), arrow function don't (this stays the same). This can be very useful.
THIS: The handling of this is also different in arrow functions compared to regular functions. In short, with arrow functions there are no binding of this. In regular functions the this keyword represented the object that called the function, which could be the window, the document, a button or whatever. With arrow functions the this keyword always represents the object that defined the arrow function.
04:39 I cant believe I've been coding for this long and never noticed this. I guess I automatically write my return statements the right way without thinking about it.
Thank you, I have worked as mainly a backend engineer over the past 4 years and have an interview for a full stack position. I haven't touched much JavaScript in a while these days and these concise videos helped me refresh my memory on these huge differences in JavaScript compared to strongly typed languages (i.e. Java, C#). Thanks again!
Thanks for these. I'd say the gotcha function call with the line break might be disregarded nowadays with Prettier and autoformatters, but still good to mention.
Could you do an example on what happens during a live coding assessment or a whiteboard session? I know this is part of the technical interview and I have NO clue what the heck happens in them.
Be confident, dont panic, even if you cant code try to think an solve the problem loud, break the problem in pieces and then try to code that with pseudocode or code
at 2:30 it is actually not correct i think. this function for example const test = () => {return "hi"}; and run it in your browser console. than run test(); it works. the reason why CODE SEMPLE 3 does not work because the Car class has to be defined. like class Car {constructor(){ this.color = () => "hi" }} than you can instantiate it with const test = new Test(); and can be called by test.greet(); so i would look into clarifying that part, at around 2:30. And by the way, great video over all, sorry for the nit picking. Good content and using it for refreshing for an interview. thank you.
The two videos you have on JavaScript interview questions are enough to study or do we still need to study leetcode? Also, will we be asked React questions? ❓
Once you say "I Should set a counter" I stop listening the video an start couting the word function an cheeck the counter to see if it's wrong jejejejeej
Si, JavaScript autoañade un ; al final del return porque no hay nada que continúe en la misma linea, en este caso está en la siguiente línea entonces no retorna nada y deja de ejecutar la función. En el ejemplo es: Return { }. Las llaves con indicaciones están en la línea de abajo y JS solo leyó el return.
I tried this : function run(){ console.log(1); setTimeout(function(){console.log(2),1000}) setTimeout(function(){console.log(3),0}) console.log(4); } run(); output is: 1 4 2 3 so 2 won't be console logged last But thanks for this i didnt know about this order of preference .
The main difference between regular and arrow functions is a context (this): regular function changes context (this = parent object), arrow function don't (this stays the same). This can be very useful.
THIS:
The handling of this is also different in arrow functions compared to regular functions.
In short, with arrow functions there are no binding of this.
In regular functions the this keyword represented the object that called the function, which could be the window, the document, a button or whatever.
With arrow functions the this keyword always represents the object that defined the arrow function.
04:39 I cant believe I've been coding for this long and never noticed this. I guess I automatically write my return statements the right way without thinking about it.
One big one for arrow functions is the this reference.
The biggest one I think. If ask a candidate to name the key difference between arrow and normal functions, I expect this answer
Thank you, I have worked as mainly a backend engineer over the past 4 years and have an interview for a full stack position. I haven't touched much JavaScript in a while these days and these concise videos helped me refresh my memory on these huge differences in JavaScript compared to strongly typed languages (i.e. Java, C#). Thanks again!
I’m really glad you found it useful!
Thanks for these.
I'd say the gotcha function call with the line break might be disregarded nowadays with Prettier and autoformatters, but still good to mention.
THE MAIN difference for arrow functions is that they don't have the synonym "this".
That should be mentioned by anyone facing that question.
Today is my very first interview day and this video already helped me a lot. Thank you! I just subscribed and I'll keep track of your videos
Thank you much and good luck on your interviews!
How did the interview go?
@@kardi3107 that one was not that good but I got hired in the second interview 😅. Been working over 3 months
@@cr7forever7877I'm almost done my JavaScript course. How do I prepare for interview questions?
Could you do an example on what happens during a live coding assessment or a whiteboard session? I know this is part of the technical interview and I have NO clue what the heck happens in them.
Be confident, dont panic, even if you cant code try to think an solve the problem loud, break the problem in pieces and then try to code that with pseudocode or code
Amazing explanation Thank you sooo much
Really glad you liked it. I have a few more videos that you may like as well!
I am addicted more please
you forgot to mention about the this scope which is the actual key difference between arrow functions and regular functions
and the this keyword!
I believe the word you mean is "context" not scope
Woo hoo! I knew most of the answers. Except the last questions #4.
Perfect video !thankss
This really helps, thanks for the video!
awesome, thank you Catherine, this was awesome
This is so helpful Catherine. Thanks for the video! :)
You’re welcome! Glad you found it useful
at 2:30 it is actually not correct i think. this function for example
const test = () => {return "hi"};
and run it in your browser console. than run test(); it works. the reason why CODE SEMPLE 3 does not work because the Car class has to be defined. like
class Car {constructor(){
this.color = () => "hi"
}}
than you can instantiate it with
const test = new Test();
and can be called by
test.greet();
so i would look into clarifying that part, at around 2:30. And by the way, great video over all, sorry for the nit picking. Good content and using it for refreshing for an interview. thank you.
Thank you for this.
You’re awesome thank you for sharing your experience 😊
One thing though is that promises are taken to the micro task queue which takes precedence over the callstack. While SetTimeouts etc do not.
Important correction: micro task takes precedence over macro-task queue, NOT the callstack. Basically priorities are always as follows:
#1 callstack
#2 micro tasks queue (resolved promises)
#3 macro tasks queue (like events callbacks, timeouts etc)
This is gem❤️
very informative I also noticed your nice hair
Great video. It was very helpful 🙌🏽
great video , thank you !!
The two videos you have on JavaScript interview questions are enough to study or do we still need to study leetcode? Also, will we be asked React questions? ❓
You'll still need to brush up on leetcode and React, with way more competition for jobs now, hiring managers are asking detailed questions.
4:50 It will throw syntax error, and won't return undefined.
Unexpected token '}'
Does front end die ?
Thank you!
Once you say "I Should set a counter" I stop listening the video an start couting the word function an cheeck the counter to see if it's wrong jejejejeej
The example with object returning is mindfulness test)
Great video!
Thank you
You’re welcome thanks for watching!
im definitely not passing an interview wow!
This is ok but I got asked all these in my junior position screening interview, what am I gunna get in my second and more technical interview?
What did u get asked? 😅
la penúltima pregunta, acerca de la diferencia entre foo1() y foo2() ¿se debe al salto de línea según entendí?
Si, JavaScript autoañade un ; al final del return porque no hay nada que continúe en la misma linea, en este caso está en la siguiente línea entonces no retorna nada y deja de ejecutar la función.
En el ejemplo es:
Return
{
}.
Las llaves con indicaciones están en la línea de abajo y JS solo leyó el return.
The foo1 and foo2 question at 4:21 is seriously a screw-up in JavaScript.
I love your videos
Thank you!!!
@@catherinelijs make more of these, maybe create a playlist..all the best..love from India
Awesome 😎
Thanks!
Thanks
Thanks!!!
You’re welcome Elias!
2:34 is wrong. You can use them as object constructors, just put braces around them
array1.map(function(x) => {
return x*2
})😅
I come from Asia and I thought you look like Asian, your video is very helpful and your voice very easy to hear. Thank you so much!!!
She really put that counter up there, lol.
Did you really use jQuery for the promise example?🤭
@3:49 did you say the f word ? I dont blame you lol
🤐
@@catherinelijs its ok your secret is safe 🤫
Idk if anyone ever told you this but you have a midwest accent, especially when you say javascript
lol first time I heard that! So I can move to Minnesota and nobody would suspect a thing? 🤔
I tried this :
function run(){
console.log(1);
setTimeout(function(){console.log(2),1000})
setTimeout(function(){console.log(3),0})
console.log(4);
}
run();
output is:
1
4
2
3
so 2 won't be console logged last
But thanks for this i didnt know about this order of preference .
You wrote it incorrectly
Don't understand... I need to learn more 😩
How can i contact you ma'am ?
Malady
thanksCat ()
İ am so cooked
Great video!
Thanks Trini!