Tricky JavaScript interview questions and answers
HTML-код
- Опубликовано: 1 окт 2024
- Top 10 Trickiest weirdest JavaScript Interview Questions and their possible answers ( path to crack tough JS interview )
Please be my patreons on patreaon
* / techsith
Follow me for technology updates
* / techsith
* / techsith1
Help me translate this video.
*
This one is important for JS developers.
Thanks for watching ! :) Thanks for the support ! )
Very helpful, your you defeated the Google beast
"This is an INTERVIEW, not a RACE" -techsith ☝️
This question with "returning total number of arguments" can be solved in much simpler way.
const x = function(){
return arguments.length;
}
The object 'arguments' has property ''length'.
You are either wrong or you mean the opposite.
the below returns 4
function x(a,r,t){
return arguments.length;
}
console.log(x(5,5,6,7))
you can count formal parameters (aka "required arguments") with function.length, not arguments.length, which is a count of what's passed.
I was thinking the same thing, but also what's the point of no loops? How would a loop even help solve this problem lol.
output will be 4
x(.....) function will return how many arguments you are passing while calling x(....).
6:10
That's a cool trick to impress your co-workers,
If they dont know it 😂😂
For getting total number of arguments, in ES6 we can do
let x = function (...args) {
return args.length;
}
and for the method chaining we can use
return this;
There is no inappropriate content in this video, dear RUclips
This is great, I have a couple of job interviews next week for JavaScript roles and you have really helped me to build my confidence in preparation for this. Please keep posting videos :-)
'Document.body.cotentEditable = "true" ' is super cool !!!
Yes first time i saw contentEditable I was blown away. :)
Very interesting JavaScript question! Thank you for sharing!! Thank you for taking time and effort to make so many nice JavaScript videos!
This video is great but and your explanation is good.
I really did't understand the concept of asking these kind of questions in interview. Until and unless you faced these kind of scenarios in real time you never know the answer. I do have some decent experience like 6+ in JS but I faced these situations very rare when we work on framework. (9 out of 10 developers dont remember things after fixing an issue)
So if some one answered these kind of questions means they saw these videos(assume {some number} out of 10) or read somewhere. So what are you interviewing real time experience or some interview preparation ?
As an interviewer I will ask concepts(not these tongue twisters). architecture of application/framework and mainly approach on solving problem and wiling to learn.
To print the length of arguments (17:33), we can simply write:
return arguments.length;
inside the function instead of using Slice method.
That is true Arjun. Slice helps to convert argument to an array and then you can use other array features like join() and things.
Hi, Please elaborate as why arguments[0]() is causing this.length as 2. What makes arguments behave like that.
Love those tricky questions, we actually keep learning :)
Great video, very useful
Hi Thanks for video but I have a doubt
String({}) +String([]) will give me "[object Object]"
but {} + [] will results in 0
Can you tell me the reason behind this?
Brother you are one of the most efficient teachers for teaching programming on youtube that i could find.You explain concepts really well.Its sad that youtube is doing this to constructive youtubers like you.You have all my support!
Very informative video . it's really help me. Thank You Sir
Please keep up the awesomeness.
I’m just here to tell youtube this video is important!!
Thanks for the comment buddy!
I've been watching your videos over the past few days and they've been extremely helpful and informative!
Thanks for watching Ninti! :)
This video is important video for ui developers. Very informative video infact.
I learned new things. Thank you clearing my Concept 😇
Thanks for making this video which helps me understand tricky concepts of JavaScript. Thanks a bunch
Thanks for tricky question - didn't aware of this magic
Why don't you use a simplier way to figure out how many arguments the function has received?
let x = function () {
return arguments.length;
}
console.log(x(1,2,3,4,5))
Yes, that is the solution . I have a habit converting arguments object to an array . :)
Thanks! Great video!
Hope RUclips will change its policy, keep it up please)
Thanks for the support ! )
very good videos
my first javascript interview coming up very soon
Good luck!
There is no inappropriate content in this video, dear RUclips
Getting ready for my first interview, your content is really helpful
Good luck with your interview. !
I am following you since couple of months.. You are champ man. Keep it up.. 1000 likes from my side
Hi Subrat, thanks for watching! :)
One of the best tutorial :)
Awesome tutorials man.
Jake Kim
Hi
your videos are awesome and RUclips is very discouraging. Keep up the good work sir.
Best Interview series!
There is nothing inappropriate in this video RUclips. Grow up, this is really frustrating for the admin/owner of page as he is working so hard on content and good things.
Thanks for your support Rashid.
Great interview questions 👍🏻
Thanks for watching ! :)
Wonderful to learn this. Thank you
Very helpful input, many thanks
Nice video, keep up the good work! (:
Thanks for the support ! )
superb tricky questions. thank you so much and it is really appreciable.
You are most welcome
Thanks for making this video. Its a great help for guys like us.
Sufiyan, thanks for the comment.
really helpful for learning strange things about javascript.
Ishan, yes JS is strange and I find new strange things every single day.
Thanks sir
So nice of you
Nice video I just feel awesome and think it about in different prospective so please update more more videos to learn more and moRe
Thanks for watching Nidhi :)
Very great Job. Tha k you so much
Good video. Posting comments so youtube can get off your back.
Thanks buddy!
you are great at teaching. very useful examples to understand js
Thank you Diksha, Keep on learning!
I liked even before video started
this video is important for JavaScript developers !!
Thanks for watching Sourav!
we can get the total number of argument simply using arguments.length right?
let x = function(){
return arguments.length;
}
console.log(x(1,2,3,4,5))
Good educational video. 👍
Very helpful videos
Love yours videos tech sith
This video is important
This video does not contain any inappropriate content and can be accessible to all ages..
Thanks Mihir
that thing at 3:50 must be the stupidest thing that javascript allows us to make.
Yes, among the other stupidest things that javaScript allows us to make :)
1) "[object Array][object Array]" Failed
2) "hello" Success
3) You would need an extension Failed
4) undefined Failed
5) "1" Success
6) 0.30000000000000001 I checked it and in 64-bit the answer is correct
7) null Success
8) function(){ return arguments.length }
9) var A={
x:function(){
console.log("x");
return this;
},
y:function(){
console.log("y");
return this;
},
z:function(){
console.log("z");
return this;
},
}; Success
I really like this video
very important video.
Thanks for making this video which helps me understand tricky concepts of JavaScript. Thanks a bunch
Good video to understand JavaScript concepts in depth
Hi,
For simplicity of typing I have used iife...
Why you have done like this ? any benefit?
(function x (a , b, c, d) {
return [].slice.call(arguments).length;
})(1, 2, 3, 4);
Instead of simply returning length of arguments array like-
(function y (a , b, c, d) {
return arguments.length;
})(1, 2, 3, 4);
Thanks,
Rahul
2 more easy way to get the numbers of arguments
const x = (...a) => a.length;
console.log(x(1, 2, 3, 4)); //4
let y = function (){return arguments.length };
console.log(y(1, 2, 3, 4, 5, 6, 7)); //7
Superb boss
@17.25, a more concise solution is: const x = (...rest) => rest.length;
Awesome video, Techsith. I'm 100% subbed 🏆🎊. Most of these questions really had be thinking haha
If my job interview clear I will donate on patron.
I appreciate the gesture Rushabh. Thank you for watching!
very informative
Hey "youtube" if you are listening "THIS VIDEO IS VERY VERY IMPORTANT FOR US DID YOU UNDERSTAND!".
good one
Awesome video! :)
Great video 👍🏻
Hey Bro,
Your Sessions are great but kindly do update the answers based on current browser version i checked console.log({} + []) and i have received "[object Object]" because on typecasting the object we get Sting({}) --> "[object Object]"
Thanks for your work.
console.log(arguments.length);
vs
console.log([].slice.call(arguments).length);
Very well explained. Thanks Sith
Thanks for watching Jaffer.
Really helpful :)
function a() {
console.log(arguments.length);
}
Above will also work for arguments length.
best video (Y)
Useful video
You helped me a lot in job interviews.
Actually I am preparing for an interview right now with the help of your video.
Thank you!
Good question
ty
great video
Thankful for good bunch of Interview questions ons JS.
All the videos are career-boosting!!!
Glad you fee that way. Thanks for the support.
instead of document.body.contentEditable = true; you could also use document.designMode = 'on';
arguments is ArrayLike, so .length is available without magic with array object and borrowing function. But most of questions quite interesting,
Nice.. on the contrary google should come up with new things to sort out issue w.r.t to ads..
Now a days utubers are getting views just by imposter thumnails..
And here utube just fails to recognize nice content like yours..
about function returns total number of arguments: Isn't it easier doing something like the following? Thanks!
let x = function(){
return arguments.length;
}
question : function return total number of arguments. // do not use loops.
let x = function(){
return [].slice.call(arguments).length;
}
Below one is more simple :
let x = function(){
return arguments.length;
}
Awesome video
Great video
great video
Good content!
nice trick...
This is very helpful to understand JavaScript internal technical execution and it's improve my knowledge
console.log({}+[])
gives [Object Object]...kindly explain.
/ It is not possible to determine the total number of arguments without using any loops or iterative constructs. In order
// to count the total number of arguments, you will need to use some form of loop to iterate over the arguments and increment
// a counter for each one.
// In JavaScript, you can access the arguments passed to a function using the arguments object, which is an array-like object that
// contains the values of the arguments. You can use a for loop to iterate over the arguments object and count the number of arguments. Alternatively, you can use the Array.prototype.length property to get the number of elements in the arguments object.
function x(){return arguments.length;} this also works then is there are any specific reason to use [].slice.call(arguments).length ?
good content
hello i was trying the first one consol.e.log({} + []); object + array that's are empty.Is the output an object is that correct? I am confused.
What's the point of converting the arguments object into a real array (17:01)? The arguments object has the length property. You could just have returned arguments.length