Tricky JavaScript interview questions and answers

Поділитися
Вставка
  • Опубліковано 30 вер 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.
    *

КОМЕНТАРІ • 1,1 тис.

  • @vinodhkumar457
    @vinodhkumar457 6 років тому +82

    This one is important for JS developers.

    • @Techsithtube
      @Techsithtube  6 років тому +6

      Thanks for watching ! :) Thanks for the support ! )

    • @JLO72713
      @JLO72713 3 роки тому

      Very helpful, your you defeated the Google beast

  • @rojiherrera
    @rojiherrera 6 років тому +21

    "This is an INTERVIEW, not a RACE" -techsith ☝️

  • @zajebojca
    @zajebojca 6 років тому +37

    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'.

    • @cassavandumbi2734
      @cassavandumbi2734 6 років тому +1

      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))

    • @dand8282
      @dand8282 6 років тому +2

      you can count formal parameters (aka "required arguments") with function.length, not arguments.length, which is a count of what's passed.

    • @kamoroso94
      @kamoroso94 6 років тому +1

      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.

    • @ravikumargrandhi6315
      @ravikumargrandhi6315 5 років тому

      output will be 4

    • @ravikumargrandhi6315
      @ravikumargrandhi6315 5 років тому +1

      x(.....) function will return how many arguments you are passing while calling x(....).

  • @astro-zodiac
    @astro-zodiac 2 роки тому +2

    6:10
    That's a cool trick to impress your co-workers,
    If they dont know it 😂😂

  • @pavelerokhin1512
    @pavelerokhin1512 6 років тому +22

    There is no inappropriate content in this video, dear UA-cam

  • @GabrielVasile
    @GabrielVasile 5 років тому +4

    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;

  • @xuelianwang5300
    @xuelianwang5300 5 років тому +5

    Very interesting JavaScript question! Thank you for sharing!! Thank you for taking time and effort to make so many nice JavaScript videos!

  • @nandac2820
    @nandac2820 5 років тому +1

    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.

  • @robertmasters5578
    @robertmasters5578 6 років тому +4

    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 :-)

  • @anuranjansrivastav9864
    @anuranjansrivastav9864 6 років тому +1

    Hi, Please elaborate as why arguments[0]() is causing this.length as 2. What makes arguments behave like that.

  • @ArjunKesava
    @ArjunKesava 5 років тому +4

    To print the length of arguments (17:33), we can simply write:
    return arguments.length;
    inside the function instead of using Slice method.

    • @Techsithtube
      @Techsithtube  5 років тому +1

      That is true Arjun. Slice helps to convert argument to an array and then you can use other array features like join() and things.

  • @CodersGyan
    @CodersGyan 4 роки тому

    One of the best tutorial :)

  • @LolowBlazee
    @LolowBlazee 6 років тому +8

    Love those tricky questions, we actually keep learning :)

  • @discountmilakya6143
    @discountmilakya6143 4 роки тому +1

    Very informative video . it's really help me. Thank You Sir

  • @vinikett9114
    @vinikett9114 4 роки тому +4

    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!

  • @sistlavenkatesh2993
    @sistlavenkatesh2993 3 роки тому +1

    This video is important video for ui developers. Very informative video infact.

  • @momentswithmanisha
    @momentswithmanisha 4 роки тому +3

    I learned new things. Thank you clearing my Concept 😇

  • @devolee8302
    @devolee8302 5 років тому +2

    'Document.body.cotentEditable = "true" ' is super cool !!!

    • @Techsithtube
      @Techsithtube  5 років тому

      Yes first time i saw contentEditable I was blown away. :)

  • @ryanlozon5712
    @ryanlozon5712 6 років тому +7

    Please keep up the awesomeness.

  • @AjayKumar-pp3ys
    @AjayKumar-pp3ys 5 років тому +1

    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?

  • @nintichance
    @nintichance 6 років тому +4

    I've been watching your videos over the past few days and they've been extremely helpful and informative!

  • @genatokarev810
    @genatokarev810 5 років тому +1

    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))

    • @Techsithtube
      @Techsithtube  5 років тому

      Yes, that is the solution . I have a habit converting arguments object to an array . :)

  • @RajendraTaradaleBeHappy
    @RajendraTaradaleBeHappy 5 років тому +3

    Thanks for tricky question - didn't aware of this magic

  • @yakirifrah
    @yakirifrah 5 років тому +1

    Thanks for making this video which helps me understand tricky concepts of JavaScript. Thanks a bunch

  • @vlad981
    @vlad981 6 років тому +4

    Thanks! Great video!
    Hope UA-cam will change its policy, keep it up please)

  • @jomesias
    @jomesias 4 роки тому +2

    I’m just here to tell youtube this video is important!!

  • @tochukwuibe2139
    @tochukwuibe2139 5 років тому +3

    Getting ready for my first interview, your content is really helpful

    • @Techsithtube
      @Techsithtube  5 років тому +1

      Good luck with your interview. !

  • @TheUltimateTrainJourney
    @TheUltimateTrainJourney 4 роки тому +1

    There is no inappropriate content in this video, dear UA-cam

  • @theinternetcash
    @theinternetcash 5 років тому +3

    my first javascript interview coming up very soon

  • @rashidahsan649
    @rashidahsan649 4 роки тому +1

    There is nothing inappropriate in this video UA-cam. Grow up, this is really frustrating for the admin/owner of page as he is working so hard on content and good things.

  • @Vyperxgames
    @Vyperxgames 5 років тому +1

    Very helpful input, many thanks

  • @jakekim1442
    @jakekim1442 6 років тому +3

    Awesome tutorials man.

  • @TarunKumar-ne7ng
    @TarunKumar-ne7ng 5 років тому +2

    very good videos

  • @babinicz91
    @babinicz91 6 років тому +4

    Best Interview series!

  • @nidhipathak3394
    @nidhipathak3394 5 років тому +1

    Nice video I just feel awesome and think it about in different prospective so please update more more videos to learn more and moRe

  • @SK-ur3hw
    @SK-ur3hw 6 років тому +5

    Great interview questions 👍🏻

    • @Techsithtube
      @Techsithtube  6 років тому

      Thanks for watching ! :)

    • @njcoutinho1
      @njcoutinho1 6 років тому

      Wonderful to learn this. Thank you

  • @sunnychaudhary35
    @sunnychaudhary35 3 роки тому +1

    superb tricky questions. thank you so much and it is really appreciable.

  • @Toni7926
    @Toni7926 6 років тому +3

    Nice video, keep up the good work! (:

  • @deepabhatt2621
    @deepabhatt2621 5 років тому +1

    Very great Job. Tha k you so much

  • @sufiyan0011able
    @sufiyan0011able 5 років тому +1

    Thanks for making this video. Its a great help for guys like us.

    • @Techsithtube
      @Techsithtube  5 років тому

      Sufiyan, thanks for the comment.

  • @subratkumar5901
    @subratkumar5901 6 років тому +1

    I am following you since couple of months.. You are champ man. Keep it up.. 1000 likes from my side

    • @Techsithtube
      @Techsithtube  6 років тому

      Hi Subrat, thanks for watching! :)

  • @ishanmehta8201
    @ishanmehta8201 5 років тому +1

    really helpful for learning strange things about javascript.

    • @Techsithtube
      @Techsithtube  5 років тому

      Ishan, yes JS is strange and I find new strange things every single day.

  • @christmasvillage3652
    @christmasvillage3652 5 років тому +2

    your videos are awesome and UA-cam is very discouraging. Keep up the good work sir.

  • @mihirbhakta1
    @mihirbhakta1 3 роки тому +1

    This video does not contain any inappropriate content and can be accessible to all ages..

  • @michaeldavis1294
    @michaeldavis1294 6 років тому +1

    Good video. Posting comments so youtube can get off your back.

  • @dikshachavan9075
    @dikshachavan9075 5 років тому +1

    you are great at teaching. very useful examples to understand js

    • @Techsithtube
      @Techsithtube  5 років тому

      Thank you Diksha, Keep on learning!

  • @Shetu_Sharma
    @Shetu_Sharma 4 роки тому +1

    I liked even before video started

  • @MrPedala94
    @MrPedala94 5 років тому +1

    that thing at 3:50 must be the stupidest thing that javascript allows us to make.

    • @Techsithtube
      @Techsithtube  5 років тому

      Yes, among the other stupidest things that javaScript allows us to make :)

  • @007souravray
    @007souravray 3 роки тому +1

    this video is important for JavaScript developers !!

  • @aakritigangwal7659
    @aakritigangwal7659 6 років тому +2

    Thankful for good bunch of Interview questions ons JS.

  • @swethas7320
    @swethas7320 5 років тому +2

    Good video to understand JavaScript concepts in depth

  • @sohamacharya9265
    @sohamacharya9265 4 роки тому +1

    Good educational video. 👍

  • @alzz0
    @alzz0 5 років тому +1

    Love yours videos tech sith

  • @rushabhshah6373
    @rushabhshah6373 5 років тому +1

    If my job interview clear I will donate on patron.

    • @Techsithtube
      @Techsithtube  5 років тому

      I appreciate the gesture Rushabh. Thank you for watching!

  • @michaeledwin2072
    @michaeledwin2072 4 роки тому +1

    This video is important

  • @yfzhangphonn
    @yfzhangphonn 3 роки тому +1

    I really like this video

  • @angelcaru
    @angelcaru 5 років тому

    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

  • @nancycreeksong9879
    @nancycreeksong9879 5 років тому +2

    Techsith videos have been very useful to me. Thank you.

  • @sumanatprakash
    @sumanatprakash 5 років тому +1

    Very helpful videos

  • @АндрейКаменский-ш4б

    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

  • @sismith5427
    @sismith5427 3 місяці тому

    I had a js interview question that asked which year a specific JavaScript feature had been introduced... You have to wonder who writes the test questions when you read one like that...

  • @dishantkumawat7508
    @dishantkumawat7508 3 роки тому

    Hey "youtube" if you are listening "THIS VIDEO IS VERY VERY IMPORTANT FOR US DID YOU UNDERSTAND!".

  • @ollehbudiak7150
    @ollehbudiak7150 4 роки тому

    Thanks for your work.
    console.log(arguments.length);
    vs
    console.log([].slice.call(arguments).length);

  • @basitalkaff
    @basitalkaff 5 років тому +1

    Thanks for the interview questions in javascript
    Could you please explain about 4 th question ("this.length") refer to arguments?

  • @RahulPandey034
    @RahulPandey034 5 років тому

    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

  • @ernestromen1479
    @ernestromen1479 6 місяців тому

    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!

  • @ShivamGupta-th3ud
    @ShivamGupta-th3ud 5 років тому +1

    very important video.

  • @sanjaysingh-sy6zu
    @sanjaysingh-sy6zu 5 років тому +1

    Thanks for making this video which helps me understand tricky concepts of JavaScript. Thanks a bunch

  • @ozzyfromspace
    @ozzyfromspace 2 роки тому

    @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

  • @Imjaffarkhan
    @Imjaffarkhan 5 років тому +1

    Very well explained. Thanks Sith

  • @sanketatmaram
    @sanketatmaram 4 роки тому

    function a() {
    console.log(arguments.length);
    }
    Above will also work for arguments length.

  • @funcomedy2
    @funcomedy2 10 місяців тому

    Very interesting JavaScript question! Thank you for sharing!!

  • @dev_khan
    @dev_khan 6 років тому

    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]"

  • @1997jugulator
    @1997jugulator 3 роки тому

    arguments is ArrayLike, so .length is available without magic with array object and borrowing function. But most of questions quite interesting,

  • @friendlydhaba4689
    @friendlydhaba4689 4 роки тому +1

    All the videos are career-boosting!!!

    • @Techsithtube
      @Techsithtube  4 роки тому

      Glad you fee that way. Thanks for the support.

  • @nitingais5187
    @nitingais5187 4 роки тому

    This is very helpful to understand JavaScript internal technical execution and it's improve my knowledge

  • @sathishkumarcisco
    @sathishkumarcisco 6 років тому

    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;
    }

  • @Moltitudine1979
    @Moltitudine1979 3 роки тому

    about function returns total number of arguments: Isn't it easier doing something like the following? Thanks!
    let x = function(){
    return arguments.length;
    }

  • @romikonlinepotapenko3475
    @romikonlinepotapenko3475 4 роки тому

    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

  • @bilalamin273
    @bilalamin273 2 роки тому

    console.log({}+[])
    gives [Object Object]...kindly explain.

  • @pmahesh6789
    @pmahesh6789 4 роки тому

    function x(){return arguments.length;} this also works then is there are any specific reason to use [].slice.call(arguments).length ?

  • @AradhanaSinghAdecentgirl
    @AradhanaSinghAdecentgirl 6 років тому +2

    Thank you So much. It really helps.You are doing great :)

  • @abhinaw1232
    @abhinaw1232 6 років тому +2

    Its really a very good video. I liked it.

  • @androiddeveloper1
    @androiddeveloper1 6 років тому

    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.

  • @techcityideas
    @techcityideas Рік тому

    Most extreme trick questions on interviews, you never ever see use of such code in the real world of programming on the job.
    Sometimes interviewers might use some nasty questions never ever used on the job, because they already have preference for another candidate instead, or politics (want to give the role to a mate or relative, internal sourcing company - forcing client dependency, so instead make it normal/easier for the other candidate they prefer), or worried about loosing their job to the candidate if the MD (non-coder) is also in on the interview, or just immature so they are testing the candidate against their own ego instead of actually interviewing the poor candidate properly.
    In such cases, if the interviewer has bias for another candidate the questions will be realistic for the code they are actually working with.
    Code is supposed to be easily readable for the team, if they coded like that on the job, they would get fired, they would be out of the game.
    I know this post is many years ago :)

  • @supredeep
    @supredeep 6 років тому

    Great video about tricky javascript question. Thank you!!!!

  • @vads2453
    @vads2453 3 роки тому +1

    helpful insightful javascript tips

  • @miroslavspirkoski5623
    @miroslavspirkoski5623 6 років тому +2

    Thanks a lot for this video, you are really unique with this content!

  • @eaglesview
    @eaglesview 6 років тому

    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))

  • @smitmistry8501
    @smitmistry8501 6 років тому

    Getting Something new editable content and awesome tricky question. I seen your video regarding front end developer from where can i find the example or some document for this so I can keep in revise very quickly.
    Thanks

  • @nitinagrawal6637
    @nitinagrawal6637 4 роки тому

    Appreciate & yes maximum people make a list of questions to ask from the internet for the interviews & then start expecting the answers for those questions from candidates & in reality maximum interviewers also dont have any freaking idea for those answers. But current interviews have become a race, a questions/answers session, a Viva.

  • @shwetapaliwal2424
    @shwetapaliwal2424 5 років тому +1

    seriously very much needed video for developers

    • @Techsithtube
      @Techsithtube  5 років тому

      Thank you shweta for a nice comment! :)

  • @pmahesh6789
    @pmahesh6789 4 роки тому

    Your all videos so far I have been seen are really deserves thumbs up ( 👍 ), Please keep doing your good work... and hope UA-cam should not harm you.

  • @sanjeevsingh-ss8tr
    @sanjeevsingh-ss8tr 5 років тому

    Hi could please make a video on PROTOTYPE and What is Prototyping?

  • @swethavutukuru
    @swethavutukuru 4 роки тому

    u have gr8 knowledge on Javascript. I am learning a lot from u. I am looking forward for more technical videos from u.

  • @anubhapant5227
    @anubhapant5227 3 роки тому

    It's fun learning these things about javascript..👌👌👌

  • @vimalsheoran8040
    @vimalsheoran8040 5 років тому

    In the problem about getting the total number of arguments, why can't we directly do return arguments.length, it will also return the total number of arguments passed to the function. Am I missing something here?

  • @jeffreyvellingan5920
    @jeffreyvellingan5920 4 роки тому

    i hope you will have advanced wsl 2 tutorial..tnx..i like your tutorial, very informative

  • @H.N7
    @H.N7 3 роки тому

    An easier solution for printing out length of arguments passed to a function is to just use const x = (...args) => console.log(args.length);

  • @nathanthomas1742
    @nathanthomas1742 6 років тому

    I have an interview as a junior developer soon and I cant answer any of these questions. Hopefully they will actually ask me something more useful or else I am absolutely fucked.