JavaScript Interview questions everyone gets wrong

  Рет қаралды 32,659

Catherine Li

Catherine Li

Күн бұрын

In this video I’m going over MORE JavaScript interview questions that you might encounter in your software developer interviews. This video will feature questions that really test your understanding of common pitfalls and weird parts of JavaScript, such as “this” keyword and scope chain.
If you're new to coding and are looking for interactive coding courses that really help develop your skills, you should check out Scrimba. Using scrims, you're able to jump into the instructor's code immediately, so it's like pair programming with an experienced teacher!
Check it out using the link here: scrimba.com/?v...
As a bonus for my channel's followers, if you sign up using the link above, you'll get 20% off a Scrimba Pro subscription!
Click here for a playlist of all of my JavaScript Interview and tutorial questions: bit.ly/3Gr54ce
Subscribe to my channel! bit.ly/3DBIIRj

Пікірлер: 81
@artemsapegin
@artemsapegin Жыл бұрын
The correct answer to all of these: it won’t pass code review.
@josem3933
@josem3933 Жыл бұрын
Have an interview tomorrow and have been binge watching all your videos
@catherinelijs
@catherinelijs Жыл бұрын
Thank you! I hope you got it!
@LucianoClassicalGuitar
@LucianoClassicalGuitar 9 ай бұрын
How did it go lol
@meetkass
@meetkass Жыл бұрын
Binging all of these videos now that I am expecting some tech interviews. This is also great insight! I wish I was looking these up BEFORE when I was giving interviews. Thanks!
@triggerticker
@triggerticker Жыл бұрын
It's crazy to me that after 4 years of uni, now that I am lookinf for a new job, I am looking at this vids to prepare for interview. Most concepts aren't really used at all in real life and thus things get forgotten. Makes you question the real use of these questions xD Anyways thanks for the great vid
@catherinelijs
@catherinelijs 10 ай бұрын
Thank you and you got this! Were you able to find a job in the past 2 months?
@issamoshi
@issamoshi 28 күн бұрын
I got the last one correct lol var is reallt tricky. I've started learning javascript a few months ago and wrote several medium size applications and webpages and haven't used it even ONCE
@haidermansoor4760
@haidermansoor4760 11 ай бұрын
I specifically search for your videos lol. they have helped me previously in my interviews alot. Thanks alot Chatherine 🙌
@catherinelijs
@catherinelijs 10 ай бұрын
Thank you! I have lots more content ready so I'm really hoping it will be helpful!
@TheEletricboy
@TheEletricboy Ай бұрын
The var keyword has so little uses nowadays that its only function is to test interviewees really. Let and Const are much more reliable when reading and executing code. There's still uses obviously but it's niche that I can almost guarantee you could go 5y without even seeing a var keyword at work (or more even).
@keifer7813
@keifer7813 Жыл бұрын
The more I watch these vids, the more I cringe at my prior confidence in JavaScript
@martapfahl940
@martapfahl940 2 жыл бұрын
Do they really still ask questions including var ? I literally NEVER use var
@6-dpegasus425
@6-dpegasus425 Жыл бұрын
Same I only ever use let or const
@Latidoz_music
@Latidoz_music Жыл бұрын
Yea
@anuj1994k
@anuj1994k Жыл бұрын
I like it somuch.... kindly do more vdo based questions on javascript function
@stewart6395
@stewart6395 2 жыл бұрын
Really love these old school questions ❤ Everyone should know this
@super.heraut.officiel
@super.heraut.officiel Ай бұрын
my answers are: 1- hm... waaaait a minute! 2- what??? well, obviously the output will be something like "error at line 2" since there is an arrow missing plus the arrowed function are made, afaik, using a constant and not a variables. 3- wouldn't it be better to create the function outside the timeout? at least for lisibility. also why the function isn't named? 4- why a colon and not an equal? 5- it is 3, but... my brain is melting
@Gio-m
@Gio-m 11 ай бұрын
Wow, super straightforward thanks Catherine!
@catherinelijs
@catherinelijs 10 ай бұрын
Thanks!
@TokyoXtreme
@TokyoXtreme 7 ай бұрын
Me in 2024: "Did var ever exist in JavaScript? I've never seen it in any codebase."
@madimakes
@madimakes 10 ай бұрын
canadian confirmed, lol. also...on the first one, i've been doing python the past 2 months and i'm going to be ruined when i get back to JS...now to watch the rest of this video
@alexandersnider734
@alexandersnider734 Жыл бұрын
These are definitely good academic things to know to understand some of Javascript's history and design philosophy, but any company actually asking me this many questions about my understanding of "this" and "var" would make my really wary of moving forward. This would indicate to me that first, the company might still be using var in practice which for all intents and purposes is almost always the worst option to use for instantiation, and that second the company might be using JS for OOP, which would indicate to me a big mistake, as JS really shines now with a functional focus and there are much better languages to use for OOP. I will concede though its important to understand the context of the arrow function vs a functional declaration. I would say much more important and likely questions to get in a modern JS interview, relate to especially closures, first-class functions, and might even touch on typing with TS.
@TuanNguyen-ed9rb
@TuanNguyen-ed9rb 6 ай бұрын
why don't you think that the company is using let in their code, and they want to find a candidate that know the difference between var and let so they don't screw their code by using var everywhere?
@Phearzmeh1
@Phearzmeh1 Жыл бұрын
Thanks i never really understood arrow functions but this helps
@catherinelijs
@catherinelijs Жыл бұрын
Happy to help!
@TamPham-oe2xc
@TamPham-oe2xc 2 жыл бұрын
You better than my teacher 😂
@costcomembership4617
@costcomembership4617 2 жыл бұрын
How common are questions regarding var vs let and arrow funcs vs normal funcs? I started learning JS self taught around June of 2022 so almost everything I’ve learned and built has been with the latest syntax. Would you recommend learning more about pre-es6 topics solely to prep for interviews?
@catherinelijs
@catherinelijs 2 жыл бұрын
Your main focus should be ES6 and modern JS and frameworks. That’s where we’re all headed. For older tech companies you can look at pre-es6 topics but that’s a lower priority imo
@MehdiGlz
@MehdiGlz Жыл бұрын
Hey Costco Membership, I know this is an old comment, but for anyone out there: ime this is important to know for interviews. Last year I did a ton of interviews and these questions came up more than once, both at small companies with old stacks and big international consulting companies. So it's good to study up before interviews
@oghenefejiroprinceimene6090
@oghenefejiroprinceimene6090 5 ай бұрын
This was really nice
@KAZVorpal
@KAZVorpal 6 ай бұрын
That's why you don't commit the obscenity of putting the curly braces on the next line. They go on the same line as the statement. Always.
@aten488
@aten488 Жыл бұрын
Thank you for this video. Much needed :) .
@srirampaga2249
@srirampaga2249 7 ай бұрын
At 3:27, the settimeout example, it prints 5, 5 times. I have a question, how can it print 5 when the for Condition is false since i=5, but condition says i
@nycsuperagent
@nycsuperagent 6 ай бұрын
2:49 it’s because setTimeout runs after the for loop is completed. At that point “i” is 5. In the desired implementation “i” still goes to 5 and satisfies the for loop’s condition which then prints out the values of i WHILE i is less than 5
@cabbage-dev
@cabbage-dev Жыл бұрын
Some of these questions appear to be made before linters existed and its a wonder they keep being asked
@FelipeBasilio-s3o
@FelipeBasilio-s3o 8 ай бұрын
Awesome video!
@catherinelijs
@catherinelijs 8 ай бұрын
Thanks Felipe!
@lunchboxUFX
@lunchboxUFX Жыл бұрын
in the last question, b++ of inner() is incrementing var b = 2 of outer(), correct? (This is a closure, yes?)
@petrkavulok9753
@petrkavulok9753 Жыл бұрын
Hi Harold, it is not. in this case it appears as the line 5 is ignored completely and the console logs only line 6 in an unchanged form. To get a better understanding, look up JavaScript Hoisting. Cheers
@myPrzeslaw
@myPrzeslaw 8 ай бұрын
@@petrkavulok9753 Well, line 5 isn't ignored, it assigns NaN value to local b var (as NaN is valid result of incrementing undefined in js). But that value isn't logged and is overwritten in line 6 by the value 3.
@myPrzeslaw
@myPrzeslaw 8 ай бұрын
No. It would be a closure if line 6 did't existed (or existed without 'var' keyword). Once you declare var x anywhere in the function (even in its last line) THE WHOLE SCOPE OF FUNCTION don't have access to outer scope var x at ANY LINE (even BEFORE initialization).
@margaret8114
@margaret8114 Жыл бұрын
So helpful!
@catherinelijs
@catherinelijs Жыл бұрын
Thanks so much!
@Everafterbreak_
@Everafterbreak_ Ай бұрын
thats wrong, example 2 logs 21, the function has access to the global scope, and the var x hasn't been declared in the function scope yet. you can test it yourself if you want to.
@issamoshi
@issamoshi 28 күн бұрын
it actually returns undefined
@crowtek2503
@crowtek2503 2 жыл бұрын
Thank you for the tips 😊
@islamfahmy9784
@islamfahmy9784 Жыл бұрын
Thank you so much
@MengLinMaker
@MengLinMaker Жыл бұрын
I prefer to use "const" if possible, then "let" and avoid "var" due to the strange behaviours it causes
@myPrzeslaw
@myPrzeslaw 8 ай бұрын
And it's great and modern approach but if company you applying to also maintains some pre ES6 code it is valid approach to examine candidates it that regard.
@adrianibarra9589
@adrianibarra9589 Жыл бұрын
LOL i have 3 years of experience and the first one got me haha
@ohyr8948
@ohyr8948 2 жыл бұрын
Can I Wait for your INTERESTING front-end web devlopment course?
@maksworldwebboy1119
@maksworldwebboy1119 Жыл бұрын
The answer for the last question is Nan ;)
@myPrzeslaw
@myPrzeslaw 8 ай бұрын
No, NaN indeed is the result of incrementation in line 5 but it is not console logged. Console logs the result of assignment from line 6.
@thisisYirou
@thisisYirou Жыл бұрын
The second example, console.log(x) would actually return 21 instead of undefined. Yes variable x is hoisted, but code runs from line 1 and below. So if girl() is invoked, that means at that point x is initialized with the value of 21. (if you try in your browser)
@tunacant9106
@tunacant9106 Жыл бұрын
Nah, it would be undefined, because inside the girl function, x is undefined.
@vivekcse1
@vivekcse1 Жыл бұрын
@@tunacant9106 On Mac, it gave me 21. Let me try it on PC.
@vivekcse1
@vivekcse1 Жыл бұрын
On windows also it's giving me 21. So this girl's premise is false. This is like a closure. But the higher order function being non-existent, global scope is taking over.
@agmonblynkos
@agmonblynkos Жыл бұрын
​@@vivekcse1the real reason it logs 21 is because var is also adding the variable to the window, which is where the console.log takes the result from. Try with let or const, it will log undefined
@myPrzeslaw
@myPrzeslaw 8 ай бұрын
It's not. JS hoisting is performed before running the code. It means interpreter firstly moves all the local vars declarations to the top of the scope (but leaves initializations in its original line). The only way var x still has its value from higher scope it has to not be declared ANYWHERE inside girl-scope.
@downanddirtytruth
@downanddirtytruth Жыл бұрын
Well. I'd have failed... I haven't invested much time into var. It's throwing me off quite badly.
@moneyDev1111
@moneyDev1111 2 жыл бұрын
const happy = new Year('🌟')
@catherinelijs
@catherinelijs 2 жыл бұрын
Same to you! All the best in 2023
@lqueryvg
@lqueryvg 3 ай бұрын
1. Don't use `var`. Ever. 2. If an interviewer obsesses about code behaviour when using `var`, it's a red flag; don't take the job.
@betatester03
@betatester03 8 ай бұрын
Javascript is such an obnoxious language.
@computeraidedyami
@computeraidedyami Жыл бұрын
You are like a god
@k-yo
@k-yo 6 ай бұрын
Honestly, these kinds of trick questions are really dumb. It tests a subset of edge-cases you wont usually stumble upon on real projects. I hate this.
@ziadomar5057
@ziadomar5057 2 жыл бұрын
Thank you and you are so beautiful
@anasouardini
@anasouardini Жыл бұрын
If only JS and browsers didn't suck, interviewers wouldn't have the chance to ask us these useless stupid questions. In the question about `setTimeout`, it's not because it's asyncronous but because browsers copy references instead of values.
@myPrzeslaw
@myPrzeslaw 8 ай бұрын
I don't think working as a JS dev is anyhow mandatory. But if you intend to do, it's pretty important to understand how do closures work.
@nittamonisudeepchand5325
@nittamonisudeepchand5325 Жыл бұрын
😍
@gourabsarker9552
@gourabsarker9552 2 жыл бұрын
Mam how much do you earn as a software engineer? Plz reply. Thanks a lot.
@yusuf-w2o4o
@yusuf-w2o4o 3 ай бұрын
I'll puke soonly because of this industries nonsenses. I failed the interview before I see this. They didn't even test my algorithm knowledge. Instead they prefered to ask these type of questions and stricly wait the answers.
@CaliburPANDAs
@CaliburPANDAs 2 жыл бұрын
Welcome back Catherine :) do you has twitter?
@catherinelijs
@catherinelijs 2 жыл бұрын
Thanks! I’m setting up new social media accounts and will post the links on this channel soon
@dbarless
@dbarless Жыл бұрын
always. add. semicolons.
@КатяСаввова
@КатяСаввова 8 ай бұрын
always; add; semicolons;
@josecastroesq
@josecastroesq 2 жыл бұрын
This video is gold. 🪙 Thank you for your content!
@catherinelijs
@catherinelijs 2 жыл бұрын
Thank you!
Гениальное изобретение из обычного стаканчика!
00:31
Лютая физика | Олимпиадная физика
Рет қаралды 4,8 МЛН
BAYGUYSTAN | 1 СЕРИЯ | bayGUYS
36:55
bayGUYS
Рет қаралды 1,9 МЛН
Nail the Javascript technical interview
12:54
Catherine Li
Рет қаралды 11 М.
Everyone makes this mistake in their interviews
9:00
Catherine Li
Рет қаралды 2,3 М.
Javascript Interview Questions and Answers - Dominate Your Next Interview
1:02:33
Monsterlessons Academy
Рет қаралды 76 М.
Coding Was HARD Until I Learned These 7 Things...
7:46
Web Developete
Рет қаралды 3,2 М.
40+ MOST COMMONLY Asked Questions [JS, CSS, HTML]
16:17
A Software Engineer
Рет қаралды 45 М.
Biggest Lies in Software Engineering
8:48
Catherine Li
Рет қаралды 69 М.
10 JavaScript Interview Questions You HAVE TO KNOW
13:41
James Q Quick
Рет қаралды 85 М.
How I'd learn to code if I had to start over
11:27
Catherine Li
Рет қаралды 64 М.