Top 10 JavaScript Interview Questions
HTML-код
- Опубликовано: 1 окт 2024
- Top 10 commonly Asked JavaScript Interview Questions and its possible answers.
For more interview questions checkout
*www.fullstack....
*My Udemy Courses
www.udemy.com/...
www.udemy.com/...
Follow me for technology updates
* / techsith
* / techsith
* / techsith1
* / 13677140
* / patelhemil
Help me translate this video.
* www.youtube.co...
Note: use translate.goog... to translate this video to your language. Let me know once you do that so i can give you credit. Thank you in advance.
Today I got a job offer from an amazing company after passing their javascript interview questions. Luckily I watched your videos shortly before the interview which contained several of the questions you answered in your videos. Thank you techsith!
Great News Shay 👍 , I am happy for you. Work hard and you will be successful.
@shay Hawking what will know to clear javascript interview for freshers
Congratulations
please add your questions here.. it'll help a lot
:)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
what is the difference between "var" and "let" keywords? 1:15
what is the difference between "==" and "===" signs? 3:54
what is the difference between "let" and "const" keywords? 6:02
what is the difference between "undefined" and "null" keywords? 9:06
what is use of Arrow function? 10:01
Not all heroes wear suit.. Thanks :)
Thanks, I already know all of these answers so you saved me some time.
Thanks
Tutorial turns out to be a giant tutorial 11:47
Tutorial turns out to be a giant tutorial 11:58
@@ChristopherElwell lol
i they asked me 3 same questions.. just completed phone interview.. and it went not that bad thanks to you 🙌🏻
I am unable to get how in the last example it would set it to window object.
It is using splitname's this which does not have firstname property so it should throw an error.
Ppppp
Ppppppp
sir what is the difference between callback function and promise .. they both run a function after they finish one.. let me try difference then you can correct me if I am Wong ..in callback function we can pass the argument of the previous function where as promise functions are independent functions. please reply
thank you for the video!
but I should point that both "let" and "var" are both always hoisted. The difference is that let gets hoisted to the block scope and remains uninitialized , that's why we get an error if we try to access it before its assignment. This is known as the "temporal dead zone". The same happens with "const".
let and const keywords are not hoisted, but temporarily declared in the temporal dead zone, until they are initialized. To be precise, TDZ is the actual reason that contradicts the concept of hoisting in case of both keywords. TDZ is a fascinating topic for newbies, but one must understand its depth and absoluteness.
Thanks to your Interview Questions video, it prepped me to land multiple Web Development jobs. I really appreciated it.
😜😜😜😜😜😜 sarcasm at its best
Got the interview today, exactly the second question be asked. I hoped earlier to see this video! 😭
Good luck I hope you get the job. :)
no reply that means no job
@@deepanshu2015 🤣🤣
Finally after 10 videos I watched your and learned what closure is :)
Started learning javascript couple months ago and this is quite helpful, thank you! (Especially the arrow)
Let and const also gets hoisted not only var
Update from 2021:
2:28 - Incorrect statement. Variables declared with let and const get hoisted as well. They just do not get initialized in the same way as with var.
Akshay saini😎
In the second question (==/===) you are talking about effect of the comparison of these 2 operators not about them functionallity. Double equal sign also compare type but before it makes type coercion. Thats why === sign is faster than == sign.
Exactly, it's disheartening to see how many interviewers get this simple thing wrong. It denotes a lack of understanding on other parts of the language as well.
Could you explain bit more
He eludes to that around 5:20
I am unable to get how in the last example it would set it to window object.
It is using splitname's this which does not have firstname property so it should throw an error.
Just some addition. Arrow functions also do not have their own arguments, the value of arguments for arrow functions are taken from the outer lexical environment.
Just Found this channel... Amazingly helpful. Sub + like
Me too
I have a question which are regarding to comparison operator,
null>0 --> false
null==0 -->false
null===0-->false
null>=0-->true ?Why ? How ?
blog.campvanilla.com/javascript-the-curious-case-of-null-0-7b131644e274
This might be helpful. tl;dr it's because of the algorithm that javascript uses when dealing with relational operators
Hello,
I have a quick question. Variables defined with 'let' are also hoisted. It's just that their initialisation to 'undefined' is not done in case of 'let'. Correct me If I am wrong. Thanks
I too was wondering with this....Let and const are also hoisted but they are in temporal dead zone
dude i highly respect you from the bottom of my heart . you are what they call an expert . i have request that please keep uploading such informative videos. thank you
Contrary to what you said, let and const are also hoisted to the top of the scope but without initialization and accessing it before initializing will throw a Reference Error.
Well if you look at that way. there is no such thing as hoisting. Hoisting is the word created by JavaScript community to explain the odd behavior of var. Its just way javaScript interpreter looks at things.
@@Techsithtube And here I thought I had that concept figured out. 😁 Much appreciated anyhow. Your content is very helpful. Hats off to you. 👏👏
There is something called temporal dead zone for let and const
Thank you for explaining after each question! This video is 5 Years old but still awesome!
50% Indians views all programing language video 📹 😅
Good video. Except const c; is not assigned a value of undefined. It throws error.
Yes in the latest broser const c; would give error.
I call bullshit. The error message is clear. The behavior didn't change since you uploaded the video. Just admit it.
+31redorange08 dude he probably tried everything 5 times in the console before making the vid to be 100000% sure about everything. So i guess he is right xD
what do you think "missing initializer" means?
@@31redorange08 fuck you and stop harassing someone who put work into a video to help us, idiot
Always remember to repent of your sins (sin is transgression of YAHUAH The Father In Heaven’s LAW: Genesis, Exodus, Leviticus, Numbers, & Deuteronomy) And Have Belief On Yahusha The Messiah. HE Died and Rose three days later so that you can be forgiven of your sins!
HE Loves you! Come to HIM🙂🙂🙂🙂🙂
You are a legend, I was working on a project where I couldn't find the solution but it was simply instead of ===, use ==. 😂😂
I am glad it was helpful.
As per my understanding Let have functional and block scope and var have global scope and functional scope.
why dont we pass name in splitName, and how n is equal to name?
Some questions from my interviews:
1. How would you describe that even bubbling works?
2. calc(1)(2) returns 3. How would you write that function?
3. What do you know about ES7?
4. What is a callback function and how would you write it?
5. Adding an array to another array without using push. How would you do it?
An instance of bubbling is when a click on a button nested inside a parent(div) that also has an on click event reacts to that click
So the way to stop the propagation is by using the stopPropagatjon method
No 5
Use the spread operator
Eg
... SecondArray
@@amakauwa9724 Would .concat be acceptable too?
yoooo got any more of those? Questions like these are addicting haha
3:21 Not its 'definition', its 'declaration'. If its definition was also hoisted, it wouldn't be undefined.
what is the difference between the two approaches below
Approach 1
*************
const profile = {
firstName: '',
lastName: '',
setName: function(name) {
let splitName = function(n) {
let nameArray = n.split(' ');
this.firstName = nameArray[0];
this.lastName = nameArray[1];
}
splitName(name);
}
};
profile.setName('John Doe');
console.log(firstName);
console.log(lastName);
Approach 2
**************
const profile = {
firstName: '',
lastName: '',
splitName: function(name) {
let nameArray = name.split(' ');
this.firstName = nameArray[0];
this.lastName = nameArray[1];
}
};
profile.splitName('John Doe');
console.log(profile.firstName);
console.log(profile.lastName);
Your voice is very low and difficult to understand what you are saying as your voice is low.
I have updated my audiio equipment since than. thanks for pointing it out.
Excellent. I recently got a job which included Javascript. It was obvious to me that the interviewer watched this video. He tried to stump me and asked 6 of the questions. Thanks because I watched this video at least 10 times 👍
I am glad Charles you were able to answer the questions. Did you get the job?
techsith Yes i did, thanks again.
Thank you, this is really helping! WISH ME LUCK MY BROTHERS
Thanks for watching!
Hello, this video is really useful thank you for sharing it :) I've got a question: at 7:25 if you say that if we write “const c;” JavaScript will assign “undefined” to our constant why if we console.log(c) is returns: “Missing initialiser……” ?
[shouldn’t it return “undefined” if we console.log(c)?]
What does “Missing initialiser really mean"? That we’ve not assigned a value to our const yet?
As far as I understand, when we use the keyword “const” while declaring a variable, an initialiser for the constant is required. We cannot just declare a variable with const we need to assign a value to it, isn’t it?
Eloquent Techsith :)
Thanks for watching!
These are actual interview questions? Seriously? Are you sure? Shouldn't the interviewer ask something that measures one's knowledge and prowess, and not the rudimentary basics of the 101 of the programming language? No-one that writes JS can fail these questions.
helped alot... waiting for part3...😃😃
Someone who is disabled I can get every question correct still not get the job.
One reason why I record interviews and keep the EEOC's number on speed dail.
Sorry to hear that, I think that is totally unfair. Feel free to share those company names so we boycott them.
Only psychopaths use white code editor backgrounds.
Jk. Nice video
On train can't try but the first name arrowfunction if it said profile {this.furstnamr=firstname;
That would work wouldn't be Window right
Tomorrow is my first interview for a Jr. Software Developer position. Wish my luck!
Don't you just love the error message "Assignment to constant variable"? It should say "assignment to a constant".
Thanks alot my Pakistani friend!
I got my first IT interview ever tomorrow, wish me luck!
Good Luck with your interview.
I don't believe sewag taking programming tutorial's
starts at 1:15
Var, let, const all get hoisted. The values for let and const do not get hoisted. Small quip
JS interview series: ruclips.net/video/VcPH4FSxc7Y/видео.html
Please note that all declarations (var, let, const, function, function*, class) are "hoisted" in JavaScript.
Agree.
The difference between var and let/const during hoisting is that JS initializes the var variables with 'undefined', while it does not initialize let/const variables which results in an error during run time.
Nice video to augment all of the other great videos you create. One thing I noticed, and this is a technicality. When describing the difference between 'let' and 'var', you state that the definition of a 'var' is hoisted, but not the value. What you meant to say (I am certain) is that the DECLARATION is hoisted and not the definition. This is an important clarification that needs to be made. Keep up the good work!!
Good point. I will point that out in the description . Thanks for watching!
Sir are u the one who has teached java script. Brad .in Udemy course.reply me.
The let variable is also hoisted , why it does not print undefined answer to it is temporal dead zone concept , I guess you have to rectify that
hi
can you explain me this
var arr = readLine().split(' ').map(arrTemp => parseInt(arrTemp, 10));
split the string by charactor, and convert each element in the array to an integer.
I'm currently interviewing for new roles. Thanks for the tips.
Variable means something can vary and constant by definition is not even a variable. It's constant.
Well correct me if I'm wrong but let is also hoisted its just that it isn't initialized.
varisables declared with var creates a property on the window object
I had an interview yesterday where I was asked about let and const and i also had the undefined and null question ... a new one for me was 'explain what promises are in javascript'
wtf is that
@@vracaze you'll learn it
How are you getting the probability of one getting these questions in an interview?
Thanks for the great video! Here questions from my interviews:
github.com/wwwebman/front-end-interview-questions
Maybe this will help someone
That is a good one too. thanks for sharing!
Variable defined as let also get hoisted but not on a global execution context but in seprate space
1) what is the difference between "var" and "let" keywords?
: Var is with us since the beginig of js whereas dlet was introduced in js with es6 version of js,
Other difference between var and let is that var has function scope and let has a block scope
other diff
Var can be hoisted at the top of its function where let doesnt get hoisted(ie let doesnt exist before its definition and exists from its definition till the end of the block)
eg.
if(true){
console.log(v) --->undefined
console.log(l) --->error
var v=1;
let l=2;
}
2)what is the difference between "==" and "===" signs? 3:54
Both of these are comparison operators, but == will compare just the value and ignore type, whereas === will compare value and type
eg.
if("3"==3) ==>true if("3"===3) ===>false
3)what is the difference between "let" and "const" keywords?
you can not reassign const value, whereas for let you can even change its type, but in array
const a=[1,2,3]
a.push(4) is allowed
a wil be a=[1,2,3,4]
but you can not reassign it as a=[1,2,3,4]
4)what is the difference between "undefined" and "null" keywords?
When you define a variable but do not assign any value to it, js automatically assigns a placeholder to it as undefined(ie we do not assiign it as undefined)
Whereas when we want to clean a value we would set it to null
another imp diff is if we do
console.log(typeof(undefined))--->undefined
console.log(typeof(null))--->object
can you make a tutorial on design patterns?
Yes I am going to create some videos on design patterns.
I love your content. I have a Front End technical interview this week - thank you so much for the great content to hep me prepare!
Good luck with your interview!
@@Techsithtube please reply please
I am learning web dev by my own so please reply
Want to become frontend
Leatnt html css bootstrap facing problem in js
Please reply what topics I need to know for web dev or I need to learn whole
Ple as per frontend web role
Let and Const both are hoisted but they will be in temporal dead zone
Let is also hoisted only difference is it goes to temporal dead zone
Variables defined with let do get hoisted but they enter a time called temporal dead zone. When we declare a variable using var and try to print its value without assigning anything to it,it gives undefined as the output. But when we do the same thing using let it gives error. The time between assigning the value to be undefined and output is called as the temporal deadzone
Actually both the comparison operators "==" and "===" compare types and values both. The difference is the former allows dynamic type coercion and latter does not.
Good video though, correct me if i am wrong :)
Thanks for sharing watching your other videos, the one that has this example console.log(7 > 6 > 5 ), console.log(5 < 6 < 7 ), made me think and and I just checked that console.log(true == 1) true as u said but also console.log(false == 0) --> true
Today they asked about, diff between undefined and null, var and let, function scoped vs block scoped, how to display keys from object, how to delete keys from object, how to sort by name
I hope you were able to answer the questions. Good luck with your interviews.
Thank you for the video, it is awesome.
gotta love JS:
v is undefined
l is not defined
and these are different lol
var a = 10;
var increment = function (a) {
a = a+1;
}
increment(a);
console.log(a);
var a = {b:10};
var increment = function (a) {
a.b = a.b+1;
}
increment(a);
console.log(a.b)
can any one tell me diffrence between these two functios
in the first case function (a) {
a = a+1;
}
a is treated as a local variable, so it doesn't modify the global variable.
but in the second case 'a' is object so while passing 'a', you are actually passing reference of 'a' so it modifies the value
@@shivangiagrawal2207 thanks 👍🏿
I know this is gonna get lost in a sea of comments but I just wanted to let you know that I passed my first co-op job javascript interview because of your videos! Thanks for everything! :)
You create very informative videos with examples that serve to illuminate rather than confuse the concepts at hand. Keep up the good work.
why are there all of this positive feedbacks for this super simple questions? you should not even think about taking a job interview if you don't know this topics
Why you got to be so negative
Both Let and var are hoisted but let not initialized
didn't know variables have "definitions" that could be hoisted. those are called "declarations." eh
You said you shouldn't manually assign a variable undefined, just curious what the reason is behind it?
Those are the basics of JavaScript and a must know for everyone firsthand even before writing your first logical JavaScript program.
best javascript i learn
The difference between let and var is that , let's say that we will made a function , between we will made variable and there we will write "Hello world ".In the console will be a mistake because the visibility area of the let is in {} . Var has the global visibility and the local visibility , we can change the value of this varieble .This is simple question , but allright
Thank you so much!!!Can someone suggest me from where I should learn javascript from basic to advance.
"Let" also gets hoisted buddy, but it's just kept in temporal dead zone.
Technically there is no such thing as hoisting. When javaScript scans all the variables for a given block , its holds them for the block. Hosting is about weather that variable is available before its declaration. In using let its not because you get error. with let you get undefined. so we call variables defined with vars are hoisted.
!0 is true in js.
I think the concept you told about 'let' is not true at some point. let are also hoisted but since js allocate completely different memory for let and we can't access those variables from that memory block before initialisation. Hence the error
@02:18 Variables declared with let don't get hoisted? I thought they did get hoisted.
Very useful information!
let gets hoisted as well const get hoisted as well! They get hoisted differently that's all.Tthey go to the temporal dead zone and if you call them before the compiler reaches the variable you will get a reference error
Hi indeed explain for this..var array=[1,2,3]; var [a=2,b]=array; console.log(a+""+b);. Op is 12
Madhan was this asked in an interview? its very simple [1,2,3] = [a,b] here a=1, b=2 so a+ "" + b = 12
@@Techsithtube yep...
How it comes..[1,2,3]=[a,b]
a=2 is just default param, which means if a is null a=2 but here [1,2,3] = [a,b] so a = 1, b=2
@@Techsithtube thanks bro
Just an additional info for arrow functions, regular functions are hoisted while arrow functions are not.
@11:01 why this.firstName is set to window object?
@techsith
You are amazing at explaining things, thank you
Really concise and on spot!
Bro ur pronunciation is bad
Thank you so much sir ❤️
Great video...Really knowledgeable 🙂
👍👍👍
2:26 You said Let does not get hoisted. Where as it get hoisted and it will be in a temporal dead zone if you try to console it before initialization .
getting temporal dead zone and hoisting is two different things. if you call variable before its definition it should give you and error. in case of let that is true. var will give you undefined instead of error. because its declaration is hoisted , not the value. Temporal dead zone is because if you define the same variable outside the block.
Loved it sir. Big fan of yours.
Why is he always saying ocject while he wrote an array
you made me know some of the little things i had always assumed;
wow JavaScript never been so easy to understand before